Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
};
// Don't use ternary condition since if we put it as undefined
// It will pass to the fork as "undefined" (string) instad of not passing it at all
// __ids__: ids ? ids.join() : undefined,
if (ids) {
baseEnv.__ids__ = ids.join();
}
// Merge process.env from the main process
const env = Object.assign({}, process.env, baseEnv);
try {
const workerPath = path.join(__dirname, 'worker.js');
// if (process.pkg) {
// const entryPoint = process.argv[1];
// workerPath = path.join(entryPoint, '../../dist/specs-runner/worker.js');
// }
const child = execa.node(workerPath, args, { env });
const result = await pEvent(child, 'message');
const childResult = await child;
if (!result) {
return null;
}
const deserializedResults = deserializeResults(result);
if (!deserializedResults) return null;
if (childResult.all) {
deserializedResults.childOutput = childResult.all;
}
if (deserializedResults.type === 'error') {
if (deserializedResults.error instanceof Error) {
throw deserializedResults.error;
}
throw new Error(deserializedResults.error);
};
// Don't use ternary condition since if we put it as undefined
// It will pass to the fork as "undefined" (string) instad of not passing it at all
// __ids__: ids ? ids.join() : undefined,
if (ids) {
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
baseEnv.__ids__ = ids.join();
}
// Merge process.env from the main process
const env = Object.assign({}, process.env, baseEnv);
const workerPath = path.join(__dirname, 'worker.js');
// if (process.pkg) {
// const entryPoint = process.argv[1];
// workerPath = path.join(entryPoint, '../../dist/specs-runner/worker.js');
// }
const child = execa.node(workerPath, args, { env, nodeOptions: ['--no-warnings'] });
const result = await pEvent(child, 'message');
const childResult = await child;
if (!result) {
return null;
}
const deserializedResults = deserializeResults(result);
if (!deserializedResults) return null;
if (childResult.all) {
deserializedResults.childOutput = childResult.all;
}
if (deserializedResults.type === 'error') {
if (deserializedResults.error instanceof Error) {
throw deserializedResults.error;
}
throw new Error(deserializedResults.error);
test('disable colors if they are not supported', async t => {
const {stdout} = await execa.node(path.join(__dirname, '_fixture'));
t.is(stdout, 'testout testerr');
});
export async function setup(options) {
const { args = [], servicePath } = options
if (RUN_TEST_AGAINST_AWS) {
return
}
serverlessProcess = node(serverlessPath, ['offline', 'start', ...args], {
cwd: servicePath,
})
await new Promise((res) => {
serverlessProcess.stdout.on('data', (data) => {
if (String(data).includes('[HTTP] server ready')) {
res()
}
})
})
}
public start () {
if (this.isConnected) {
throw new Error('Http server is already connected. Call restart instead')
}
this.logger.info(this.childProcess ? 're-starting http server' : 'starting http server')
this.childProcess = execa.node(this.sourceFile, [], {
buffer: false,
stdio: 'inherit',
cwd: this.projectRoot,
env: {
FORCE_COLOR: 'true',
},
nodeOptions: this.nodeArgs,
})
this.childProcess.on('close', (code, signal) => this.emit('close', { code, signal }))
this.childProcess.on('exit', (code, signal) => this.emit('exit', { code, signal }))
}
public start () {
if (this.isConnected) {
throw new Error('Http server is already connected. Call restart instead')
}
this._httpServer = execa.node(this._sourceFile, [], {
buffer: false,
cwd: this._projectRoot,
env: getChildProcessEnvVariables(this._projectRoot),
nodeOptions: this._nodeArgs,
})
/**
* Pipe the output
*/
this._httpServer.stdout!.pipe(process.stdout)
this._httpServer.stderr!.pipe(process.stderr)
}
async function run(args, cwd, commandOptions) {
const options = Object.assign(
{
cwd,
reject: false,
all: true
},
commandOptions || {}
);
options.env = Object.assign({ TESTING_CRAFTY: "true" }, options.env || {});
const ret = await execa.node(
require.resolve("@swissquote/crafty/src/bin"),
args,
options
);
return {
status: ret.exitCode,
stdall: ret.all ? `\n${snapshotizeOutput(ret.all.toString("utf8"))}\n` : ""
};
}
public async generate () {
try {
const response = await execa.node('ace', ['generate:manifest'], {
buffer: true,
cwd: this.appRoot,
env: {
FORCE_COLOR: 'true',
},
})
/**
* Print warning when `stderr` exists
*/
if (response.stderr) {
this.logger.warn(WARN_MESSAGE)
return
}
/**