regressify 1.0.12 → 1.0.14

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.
Files changed (2) hide show
  1. package/cli.js +20 -7
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -6,20 +6,33 @@ import { fileURLToPath, pathToFileURL } from 'url';
6
6
  import chalk from 'chalk';
7
7
 
8
8
  function getLibraryPath() {
9
- const __filename = fileURLToPath(import.meta.url);
10
- const __dirname = dirname(__filename);
9
+ const fileName = fileURLToPath(import.meta.url);
10
+ let currentDir = dirname(fileName);
11
+
12
+ while (true) {
13
+ const packageJsonPath = path.join(currentDir, 'package.json');
14
+ if (fs.existsSync(packageJsonPath)) {
15
+ // We have found the package.json file
16
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
17
+ if (
18
+ (packageJson.dependencies && packageJson.dependencies['regressify']) ||
19
+ (packageJson.devDependencies && packageJson.devDependencies['regressify'])
20
+ ) {
21
+ return `node_modules/${packageJson.name}`;
22
+ }
23
+ }
11
24
 
12
- let currentDir = __dirname;
13
- while (!fs.existsSync(path.join(currentDir, 'package.json'))) {
14
25
  const parentDir = path.dirname(currentDir);
15
26
  if (parentDir === currentDir) {
27
+ // We have reached the root directory
28
+ console.log(chalk.red('Could not find package.json file in the current directory or any of its parents. Current directory:'), import.meta.url);
29
+ console.log(chalk.red('___filename:'), __filename);
30
+ console.log(chalk.red('__dirname:'), __dirname);
16
31
  return null;
17
32
  }
33
+
18
34
  currentDir = parentDir;
19
35
  }
20
- const packageJsonPath = path.join(currentDir, 'package.json');
21
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
22
- return `node_modules/${packageJson.name}`;
23
36
  }
24
37
 
25
38
  function runCommand(command) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "regressify",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "Visual regression tests support",
5
5
  "main": "index.js",
6
6
  "type": "module",