Socket
Socket
Sign inDemoInstall

@percy/cli-config

Package Overview
Dependencies
Maintainers
6
Versions
238
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@percy/cli-config - npm Package Compare versions

Comparing version 1.12.0 to 1.13.0

14

dist/create.js

@@ -52,16 +52,18 @@ import fs from 'fs';

// discern the filetype
let filetype = args.filepath ? path.extname(args.filepath).replace(/^./, '') : FILETYPES.find(t => flags[t]) ?? 'yml'; // verify the filetype is supported
let filetype = args.filepath ? path.extname(args.filepath).replace(/^./, '') : FILETYPES.find(t => flags[t]) ?? 'yml';
// verify the filetype is supported
if (!DEFAULT_FILES[filetype]) {
exit(1, `Unsupported filetype: ${filetype}`);
} // default filepath based on filetype
}
// default filepath based on filetype
let filepath = args.filepath || DEFAULT_FILES[filetype];
let filepath = args.filepath || DEFAULT_FILES[filetype]; // verify the file does not already exist
// verify the file does not already exist
if (fs.existsSync(filepath)) {
exit(1, `Percy config already exists: ${filepath}`);
} // write stringified default config options to the filepath
}
// write stringified default config options to the filepath
let format = ['rc', 'yaml', 'yml'].includes(filetype) ? 'yaml' : filetype;

@@ -68,0 +70,0 @@ fs.mkdirSync(path.dirname(filepath), {

@@ -31,13 +31,15 @@ import fs from 'fs';

if (!config) exit(1, 'Config file not found');
log.info(`Found config file: ${path.relative('', input)}`); // if migrating versions, warn when latest
log.info(`Found config file: ${path.relative('', input)}`);
// if migrating versions, warn when latest
if (input === output && config.version === 2) {
exit(0, 'Config is already the latest version');
} // migrate config
}
// migrate config
log.info('Migrating config file...');
let format = path.extname(output).replace(/^./, '') || 'yaml';
let migrated = PercyConfig.migrate(config); // prefer kebab-case for yaml
let migrated = PercyConfig.migrate(config);
// prefer kebab-case for yaml
if (/^ya?ml$/.test(format)) {

@@ -48,14 +50,13 @@ migrated = PercyConfig.normalize(migrated, {

});
} // stringify to the desired format
}
// stringify to the desired format
let body = PercyConfig.stringify(format, migrated);
if (!flags.dryRun) {
let content = body;
if (path.basename(output) === 'package.json') {
// update the package.json entry by reading and modifying it
let pkg = JSON.parse(fs.readFileSync(output));
content = PercyConfig.stringify(format, { ...pkg,
content = PercyConfig.stringify(format, {
...pkg,
percy: migrated

@@ -71,10 +72,10 @@ });

fs.renameSync(input, path.join(dir, `${name}.old${ext}`));
} // write to output
}
// write to output
fs.writeFileSync(output, content);
}
log.info('Config file migrated!');
log.info('Config file migrated!'); // when dry-running, print config to stdout when finished
// when dry-running, print config to stdout when finished
if (flags.dryRun) {

@@ -81,0 +82,0 @@ log.stdout.write('\n' + body);

@@ -19,4 +19,5 @@ import command, { PercyConfig } from '@percy/cli-command';

} = PercyConfig.search(args.filepath);
if (!config) exit(1, 'Config file not found'); // when `bail` is true, .load() returns undefined when validation fails
if (!config) exit(1, 'Config file not found');
// when `bail` is true, .load() returns undefined when validation fails
let result = PercyConfig.load({

@@ -26,6 +27,7 @@ path: filepath,

bail: true
}); // exit 1 when config is empty
});
// exit 1 when config is empty
if (!result) exit(1);
});
export default validate;
{
"name": "@percy/cli-config",
"version": "1.12.0",
"version": "1.13.0",
"license": "MIT",

@@ -35,5 +35,5 @@ "repository": {

"dependencies": {
"@percy/cli-command": "1.12.0"
"@percy/cli-command": "1.13.0"
},
"gitHead": "4303b74df91f60e36065141289d2ef2277d1d6fc"
"gitHead": "d2e812d14aa446fa580ffa75144a6280627b5a27"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc