Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
proper clean up of fabricator children. fixes #254
Browse files Browse the repository at this point in the history
  • Loading branch information
igorklopov committed Oct 20, 2017
1 parent ca94640 commit fc7b6c1
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/fabricator.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export function fabricateTwice (bakes, fabricator, snap, body, cb) {
export function shutdown () {
for (const key in children) {
const child = children[key];
delete children[key];
child.kill();
}
}
38 changes: 38 additions & 0 deletions test/test-50-api/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/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());

const target = process.argv[2] || 'host';
const input = './test-x-index.js';
const output = './test-output.exe';

let right;
utils.mkdirp.sync(path.dirname(output));

// calling twice
require('../../').exec([
'--target', target,
'--output', output, input
]).then(function () {
return require('../../').exec([
'--target', target,
'--output', output, input
]).then(function () {
right = utils.spawn.sync(
output, [], {}
);

assert.equal(right, '42\n');
utils.vacuum.sync(output);
});
}).catch(function (error) {
console.error(error);
process.exit(2);
});
3 changes: 3 additions & 0 deletions test/test-50-api/test-x-index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

console.log(42);

0 comments on commit fc7b6c1

Please sign in to comment.