Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async resolveFilesUsingGit(): Promise {
try {
const { stdout } = await childProcessAsPromised.exec(`git ls-files --others --exclude-standard --cached --exclude /${this.tempDirName}/*`, {
maxBuffer: 10 * 1000 * 1024
});
const fileNames = stdout
.toString()
.split('\n')
.map(line => line.trim())
.filter(line => line) // remove empty lines
.map(relativeFileName => path.resolve(relativeFileName));
return fileNames;
} catch (error) {
throw new StrykerError(
normalizeWhitespaces(
`Cannot determine input files. Either specify a \`files\`
array in your stryker configuration, or make sure "${process.cwd()}"
is located inside a git repository`
),
private async resolveFilesUsingGit(): Promise {
try {
const { stdout } = await childProcessAsPromised.exec(
'git ls-files --others --exclude-standard --cached --exclude .stryker-tmp',
{ maxBuffer: 10 * 1000 * 1024 }
);
const fileNames = stdout.toString()
.split('\n')
.map(line => line.trim())
.filter(line => line) // remove empty lines
.map(relativeFileName => path.resolve(relativeFileName));
return fileNames;
} catch (error) {
throw new StrykerError(normalizeWhiteSpaces(
`Cannot determine input files. Either specify a \`files\`
array in your stryker configuration, or make sure "${process.cwd()}"
is located inside a git repository`),
error
);
private async writeStrykerConfigRaw(rawConfig: string, rawHeader = '') {
this.out('Writing & formatting stryker.conf.js...');
const formattedConf = `${rawHeader}
module.exports = function(config){
config.set(
${rawConfig}
);
}`;
await fsAsPromised.writeFile(STRYKER_CONFIG_FILE, formattedConf);
try {
await childProcessAsPromised.exec(`npx prettier --write ${STRYKER_CONFIG_FILE}`);
} catch (error) {
this.log.debug('Prettier exited with error', error);
this.out('Unable to format stryker.conf.js file for you. This is not a big problem, but it might look a bit messy 🙈.');
}
}