regressify 1.0.12 → 1.0.13
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 +13 -7
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -6,20 +6,26 @@ import { fileURLToPath, pathToFileURL } from 'url';
|
|
|
6
6
|
import chalk from 'chalk';
|
|
7
7
|
|
|
8
8
|
function getLibraryPath() {
|
|
9
|
-
const
|
|
10
|
-
|
|
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
|
+
return `node_modules/${packageJson.name}`;
|
|
18
|
+
}
|
|
11
19
|
|
|
12
|
-
let currentDir = __dirname;
|
|
13
|
-
while (!fs.existsSync(path.join(currentDir, 'package.json'))) {
|
|
14
20
|
const parentDir = path.dirname(currentDir);
|
|
15
21
|
if (parentDir === currentDir) {
|
|
22
|
+
// We have reached the root directory
|
|
23
|
+
console.log(chalk.red('Could not find package.json file in the current directory or any of its parents. Current directory:'), import.meta.url);
|
|
16
24
|
return null;
|
|
17
25
|
}
|
|
26
|
+
|
|
18
27
|
currentDir = parentDir;
|
|
19
28
|
}
|
|
20
|
-
const packageJsonPath = path.join(currentDir, 'package.json');
|
|
21
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
22
|
-
return `node_modules/${packageJson.name}`;
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
function runCommand(command) {
|