Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
scripts = [...new Set(scripts)];
const scriptIndex = argv.findIndex((x) => scripts.includes(x));
const script = scriptIndex !== -1 && argv[scriptIndex];
if (!script) {
const options = logger.colors.blue(scripts.join(', '));
logger.error(`Unknown script '${script}'; please choose from one of: ${options}.`);
return process.exit(1);
}
// Print help doc and quit
if (argv.includes('--help') && script) {
const docPath = join(dir, '../docs', script) + '.md';
if (!existsSync(docPath)) {
logger.warning(`No documentation was found for ${script}`);
return process.exit(1);
}
markedRender(docPath);
return process.exit(0);
}
const nodeArgs = scriptIndex > 0 ? argv.slice(0, scriptIndex) : [];
const scriptPath = require.resolve(`./scripts/${script}`);
const scriptArgs = argv.slice(scriptIndex + 1);
const processArgs = nodeArgs.concat(scriptPath).concat(scriptArgs);
// Temp disallow version while we figure this out
if (script !== 'test') {
processArgs.push('--disallow-versioning');
}
scripts = [...new Set(scripts)];
const scriptIndex = argv.findIndex((x) => scripts.includes(x));
const script = scriptIndex !== -1 && argv[scriptIndex];
if (!script) {
const options = logger.colors.blue(scripts.join(', '));
logger.error(`Unknown script '${script}'; please choose from one of: ${options}.`);
return process.exit(1);
}
// Print help doc and quit
if (argv.includes('--help') && script) {
const docPath = join(dir, '../docs', script) + '.md';
if (!existsSync(docPath)) {
logger.warning(`No documentation was found for ${script}`);
return process.exit(1);
}
markedRender(docPath);
return process.exit(0);
}
const nodeArgs = scriptIndex > 0 ? argv.slice(0, scriptIndex) : [];
const scriptPath = require.resolve(`./scripts/${script}`);
const scriptArgs = argv.slice(scriptIndex + 1);
const processArgs = nodeArgs.concat(scriptPath).concat(scriptArgs);
// Temp disallow version while we figure this out
if (script !== 'test') {
processArgs.push('--disallow-versioning');
}
const spawn = (processArgs: string[]): number => {
const child = spawnSync('node', processArgs, { stdio: 'inherit' });
if (child.signal) {
if (child.signal === 'SIGKILL') {
logger.error([
'The build failed because the process exited too early. ',
'This probably means the system ran out of memory or someone called ',
'`kill -9` on the process.',
].join('\n'));
} else if (child.signal === 'SIGTERM') {
logger.warning([
'The build failed because the process exited too early. ',
'Someone might have called `kill` or `killall`, or the system could ',
'be shutting down.',
].join('\n'));
}
process.exit(1);
}
return child.status || 0;
};
export default (skip: boolean) => {
if (skip) {
logger.warning(
'SKIP_PREFLIGHT_CHECK=true is used and the warning is ignored; your script will continue.',
);
} else {
logger.warning(multilineString(
'If you like to skip this and proceed anyway, use SKIP_PREFLIGHT_CHECK=true environment variable.',
'This will disable checks and allow you to run your application anyway.',
));
}
};
export default (skip: boolean) => {
if (skip) {
logger.warning(
'SKIP_PREFLIGHT_CHECK=true is used and the warning is ignored; your script will continue.',
);
} else {
logger.warning(multilineString(
'If you like to skip this and proceed anyway, use SKIP_PREFLIGHT_CHECK=true environment variable.',
'This will disable checks and allow you to run your application anyway.',
));
}
};
const routeCollision = await progress('Validating the new plugin bundle', async () => {
const collision = runtime.build ? !_verifyPath(pluginBaseUrl, runtime.build) : false;
if (collision) {
if (options.overwrite) {
if (!options.disallowVersioning) {
logger.newline();
logger.warning('Plugin already exists and the flag --overwrite is going to overwrite this plugin.');
}
} else {
throw new FlexPluginError(`You already have a plugin with the same version: ${pluginUrl}`);
}
}
return collision;
});