mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 09:03:02 +00:00
refactor: adjust code to stricter rules
This commit is contained in:
12
src/cli.ts
12
src/cli.ts
@@ -37,7 +37,10 @@ const currentWorkingDirectory = cwd();
|
||||
|
||||
// configure commander
|
||||
commander
|
||||
.version(JSON.parse(readFileSync(resolve(__dirname, '..', 'package.json')).toString()).version)
|
||||
.version(JSON.parse(
|
||||
readFileSync(resolve(__dirname, '..', 'package.json'))
|
||||
.toString(),
|
||||
).version)
|
||||
.option('-p, --path <path>', `Path of project to add files to (${currentWorkingDirectory})`, currentWorkingDirectory)
|
||||
.option('-r, --replace', 'Whether to replace existing files or not', false)
|
||||
.parse(process.argv);
|
||||
@@ -54,7 +57,8 @@ if (!existsSync(resolve(path, 'package.json'))) {
|
||||
const packageJsonPath = resolve(path, 'package.json');
|
||||
|
||||
// read package.json in provided path
|
||||
const packageJson = JSON.parse(readFileSync(packageJsonPath).toString());
|
||||
const packageJson = JSON.parse(readFileSync(packageJsonPath)
|
||||
.toString());
|
||||
|
||||
// check if provided path is this package
|
||||
if (packageJson.name === '@openstapps/configuration') {
|
||||
@@ -93,8 +97,10 @@ checkCIConfig(rules, path);
|
||||
|
||||
checkCopyrightYears(path, 'src');
|
||||
|
||||
const indentation = 2;
|
||||
|
||||
if (packageJsonChanged) {
|
||||
writeFileSync(resolve(path, 'package.json'), JSON.stringify(packageJson, null, 2));
|
||||
writeFileSync(resolve(path, 'package.json'), JSON.stringify(packageJson, null, indentation));
|
||||
consoleLog(`Changes were written to '${packageJsonPath}'.`);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user