This repository has been archived by the owner on Jan 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env node | ||
|
||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const assert = require('assert'); | ||
const utils = require('../utils.js'); | ||
const os = require('os'); | ||
|
||
// ignore this test if nodejs <= 10 , as recent version of PNPM do not support nodejs=10 | ||
const MAJOR_VERSION = parseInt(process.version.match(/v([0-9]+)/)[1], 10); | ||
|
||
if (MAJOR_VERSION < 14) { | ||
console.log( | ||
'skiping test as it requires nodejs >= 14', | ||
MAJOR_VERSION | ||
); | ||
process.exit(0) | ||
} | ||
|
||
assert(__dirname === process.cwd()); | ||
|
||
const ext = process.platform === 'win32' ? '.exe' : ''; | ||
|
||
const target = process.argv[2] || 'host'; | ||
const input = './test.js'; | ||
const output = './test-output' + ext; | ||
|
||
console.log('target = ', target); | ||
utils.pkg.sync([ | ||
'--target', | ||
target, | ||
'--output', | ||
output, | ||
input, | ||
]); | ||
|
||
// check that produced executable is running and produce the expected output. | ||
const log = utils.spawn.sync(output, [], { | ||
cwd: path.dirname(output), | ||
expect: 0, | ||
}); | ||
assert(log === os.arch() + '\n'); | ||
|
||
// clean up | ||
utils.vacuum.sync(output); | ||
|
||
console.log('OK'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "test-00-esm", | ||
"version": "1.0.0", | ||
"description": "", | ||
"type": "module", | ||
"main": "test.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import os from 'os'; | ||
|
||
console.log(os.arch()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters