diff --git a/test/test-775/a.js b/test/test-775/a.js new file mode 100644 index 000000000..868fb96a3 --- /dev/null +++ b/test/test-775/a.js @@ -0,0 +1,4 @@ +console.log('Starting a'); +const { Worker } = require('worker_threads'); +new Worker('./b.js'); +console.log('Finishing a'); diff --git a/test/test-775/b.js b/test/test-775/b.js new file mode 100644 index 000000000..3ac9bea17 --- /dev/null +++ b/test/test-775/b.js @@ -0,0 +1,3 @@ +// b.js +console.log('Starting b'); +console.log('Finishing b'); diff --git a/test/test-775/main.js b/test/test-775/main.js new file mode 100644 index 000000000..cae876d42 --- /dev/null +++ b/test/test-775/main.js @@ -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); diff --git a/test/test-775/package.json b/test/test-775/package.json new file mode 100644 index 000000000..bc5669c15 --- /dev/null +++ b/test/test-775/package.json @@ -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" + ] + } +}