Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function testTask(task: TestTaskDesc): SpawnSyncReturns {
// `coverageDirectory` is necessary because the root is `src`
const cmd = 'npx';
const config = task.config || getJestConfig();
const args = [
'--no-install',
'jest',
...(config ? ['--config', config] : []),
...task.restOptions,
];
dbg('npx args %o', args);
return spawn.sync(cmd, args, { stdio: 'inherit' });
}
export function commitMsgTask(
task: CommitMsgTaskDesc,
): SpawnSyncReturns {
const cmd = 'npx';
const args = [
'--no-install',
'commitlint',
`--config=${task.config}`,
`--edit=${process.env.HUSKY_GIT_PARAMS}`,
...task.restOptions,
];
dbg('npx args %o', args);
return spawn.sync(cmd, args, { stdio: 'inherit' });
}
export function releaseTask(task: ReleaseTaskDesc): SpawnSyncReturns {
const cmd = 'npx';
const args = ['--no-install', 'semantic-release', ...task.restOptions];
dbg('npx args %o', args);
return spawn.sync(cmd, args, { stdio: 'inherit' });
}
...process.env,
WEB_SCRIPTS_SHOULD_FIX: task.fix.toString(),
WEB_SCRIPTS_RUN_TESTS: task.tests.toString(),
};
if (task.eslintConfig) {
env.WEB_SCRIPTS_ESLINT_CONFIG = task.eslintConfig;
}
if (task.jestConfig) {
env.WEB_SCRIPTS_JEST_CONFIG = task.jestConfig;
}
if (task.prettierConfig) {
env.WEB_SCRIPTS_PRETTIER_CONFIG = task.prettierConfig;
}
return spawn.sync(cmd, args, {
stdio: 'inherit',
env,
});
}
export function formatTask(task: FormatTaskDesc): SpawnSyncReturns {
const cmd = 'npx';
const config = task.config || getPrettierConfig();
const args = [
'--no-install',
'prettier',
...(config ? ['--config', config] : []),
...task.restOptions,
];
dbg('npx args %o', args);
return spawn.sync(cmd, args, { stdio: 'inherit' });
}