regressify 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cli.js CHANGED
@@ -52,6 +52,7 @@ let commandBase = `tsx ${getLibraryPath()}/src/index.ts`;
52
52
  if (command === 'init') {
53
53
  const __filename = fileURLToPath(import.meta.url);
54
54
  const __dirname = dirname(__filename);
55
+
55
56
  const postInstallPath = pathToFileURL(path.join(__dirname, 'generate_tests.js'));
56
57
  if (fs.existsSync(postInstallPath)) {
57
58
  console.log(chalk.yellow('generate folder visual_tests ...'));
@@ -59,6 +60,14 @@ if (command === 'init') {
59
60
  } else {
60
61
  console.log(chalk.red('generate_tests.js not found!'));
61
62
  }
63
+
64
+ const updatePackageJsonPath = pathToFileURL(path.join(__dirname, 'update-package.js'));
65
+ if (fs.existsSync(updatePackageJsonPath)) {
66
+ console.log(chalk.yellow('update package.json ...'));
67
+ await import(updatePackageJsonPath);
68
+ } else {
69
+ console.log(chalk.red('update-package.js not found!'));
70
+ }
62
71
  } else if (command === 'ref') {
63
72
  const command = `${commandBase} --command test --ref ${args.slice(1).join(' ')}`;
64
73
  console.log(chalk.yellow(`Running command: ${command}`));
package/generate_tests.js CHANGED
@@ -1,9 +1,11 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
3
  import { fileURLToPath } from 'url';
4
- import { ncp } from 'ncp';
4
+ import pkg from 'ncp';
5
5
  import chalk from 'chalk';
6
6
 
7
+ const { ncp } = pkg;
8
+
7
9
  async function askUser() {
8
10
  const sourceFolder = path.join(path.dirname(fileURLToPath(import.meta.url)), 'visual_tests');
9
11
  const destinationFolder = path.join(process.cwd(), 'visual_tests');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "regressify",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Visual regression tests support",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/update-package.js CHANGED
@@ -4,6 +4,11 @@ import { fileURLToPath } from 'url';
4
4
 
5
5
  async function updatePackageJson() {
6
6
  const packageJsonPath = path.join(path.dirname(fileURLToPath(import.meta.url)), 'package.json');
7
+ if (!fs.existsSync(packageJsonPath)) {
8
+ console.log(chalk.red("package.json file doesn't exists"), err);
9
+ return;
10
+ }
11
+
7
12
  const packageJsonText = fs.readFileSync(packageJsonPath, 'utf8');
8
13
  const packageJson = JSON.parse(packageJsonText);
9
14