forked from vercel/pkg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6deb812
commit 1456da1
Showing
4 changed files
with
79 additions
and
0 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,4 @@ | ||
console.log('Starting a'); | ||
const { Worker } = require('worker_threads'); | ||
new Worker('./b.js'); | ||
console.log('Finishing a'); |
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 @@ | ||
// b.js | ||
console.log('Starting b'); | ||
console.log('Finishing b'); |
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,56 @@ | ||
#!/usr/bin/env node | ||
|
||
'use strict'; | ||
|
||
const path = require('path'); | ||
const assert = require('assert'); | ||
const utils = require('../utils.js'); | ||
|
||
assert(!module.parent); | ||
assert(__dirname === process.cwd()); | ||
|
||
/* eslint-disable no-unused-vars */ | ||
const input = 'package.json'; | ||
const target = 'host'; | ||
const ext = process.platform === 'win32' ? '.exe' : ''; | ||
const output = 'output' + ext; | ||
|
||
const inspect = ['ignore', 'ignore', 'pipe']; | ||
|
||
const logPkg1 = utils.pkg.sync( | ||
['--target', target, '--debug', '--output', output, input], | ||
{ expect: 0 } | ||
); | ||
|
||
const log1 = utils.spawn.sync(path.join(__dirname, output), [], { | ||
cwd: __dirname, | ||
expect: 0, | ||
}); | ||
|
||
assert.strictEqual( | ||
log1, | ||
`Starting a | ||
Finishing a | ||
Starting b | ||
Finishing b | ||
` | ||
); | ||
|
||
const logPkg2 = utils.pkg.sync( | ||
['--target', target, '--debug', '--output', output, 'a.js'], | ||
{ expect: 0 } | ||
); | ||
|
||
const log2 = utils.spawn.sync(path.join(__dirname, output), [], { | ||
cwd: __dirname, | ||
expect: 0, | ||
}); | ||
assert.strictEqual( | ||
log2, | ||
`Starting a | ||
Finishing a | ||
Starting b | ||
Finishing b | ||
` | ||
); | ||
utils.vacuum.sync(output); |
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,16 @@ | ||
{ | ||
"name": "a", | ||
"version": "0.1.0", | ||
"description": "proof", | ||
"bin": "a.js", | ||
"license": "UNLICENSED", | ||
"devDependencies": { | ||
"pkg": "^4.4.0" | ||
}, | ||
"pkg": { | ||
"scripts": [ | ||
"a.js", | ||
"b.js" | ||
] | ||
} | ||
} |