regressify 1.0.19 → 1.0.21
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/helpers.ts +0 -20
- package/package.json +1 -1
- package/src/config.ts +1 -2
- package/src/helpers.ts +5 -15
- package/src/index.ts +2 -6
package/helpers.ts
CHANGED
|
@@ -1,27 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import path, { dirname } from 'path';
|
|
4
2
|
import { exec } from 'child_process';
|
|
5
|
-
import { fileURLToPath, pathToFileURL } from 'url';
|
|
6
3
|
import chalk from 'chalk';
|
|
7
4
|
|
|
8
|
-
export function getLibraryPath() {
|
|
9
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
-
const __dirname = dirname(__filename);
|
|
11
|
-
|
|
12
|
-
let currentDir = __dirname;
|
|
13
|
-
while (!fs.existsSync(path.join(currentDir, 'package.json'))) {
|
|
14
|
-
const parentDir = path.dirname(currentDir);
|
|
15
|
-
if (parentDir === currentDir) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
currentDir = parentDir;
|
|
19
|
-
}
|
|
20
|
-
const packageJsonPath = path.join(currentDir, 'package.json');
|
|
21
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
22
|
-
return `node_modules/${packageJson.name}`;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
5
|
export function runCommand(command) {
|
|
26
6
|
const childProcess = exec(command, { env: { ...process.env, FORCE_COLOR: '1' } });
|
|
27
7
|
|
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -23,8 +23,7 @@ if (globalRequiredLogin) {
|
|
|
23
23
|
const scenarios: Scenario[] = [];
|
|
24
24
|
|
|
25
25
|
const getScriptPath = (scriptPath: string, engine: 'puppeteer' | 'playwright') => {
|
|
26
|
-
|
|
27
|
-
return path.join(basePath, (engine == 'puppeteer' ? 'puppet' : 'playwright') + scriptPath);
|
|
26
|
+
return path.join(__dirname, '..', '.engine_scripts', (engine == 'puppeteer' ? 'puppet' : 'playwright') + scriptPath);
|
|
28
27
|
};
|
|
29
28
|
|
|
30
29
|
if (!testSuite) {
|
package/src/helpers.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import YAML from 'js-yaml';
|
|
3
|
-
import
|
|
3
|
+
import { dirname } from 'path';
|
|
4
|
+
import slash from 'slash';
|
|
4
5
|
import { fileURLToPath } from 'url';
|
|
6
|
+
|
|
5
7
|
export const getStringArg = (key: string): string | undefined => {
|
|
6
8
|
const index = process.argv.indexOf(key);
|
|
7
9
|
return index >= 0 && index < process.argv.length - 1 && !process.argv[index + 1].startsWith('-') ? process.argv[index + 1] : undefined;
|
|
@@ -23,18 +25,6 @@ export const parseDataFromFile = (dataPath: string, type: 'yaml' | 'json' = 'yam
|
|
|
23
25
|
};
|
|
24
26
|
|
|
25
27
|
export function getLibraryPath() {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
let currentDir = __dirname;
|
|
30
|
-
while (!fs.existsSync(path.join(currentDir, 'package.json'))) {
|
|
31
|
-
const parentDir = path.dirname(currentDir);
|
|
32
|
-
if (parentDir === currentDir) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
currentDir = parentDir;
|
|
36
|
-
}
|
|
37
|
-
const packageJsonPath = path.join(currentDir, 'package.json');
|
|
38
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
39
|
-
return `node_modules/${packageJson.name}`;
|
|
28
|
+
const fileName = fileURLToPath(import.meta.url);
|
|
29
|
+
return slash(dirname(dirname(fileName)));
|
|
40
30
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import backstop from 'backstopjs';
|
|
3
3
|
import config from './config.js';
|
|
4
|
-
import { getStringArg } from './helpers.js';
|
|
4
|
+
import { getLibraryPath, getStringArg } from './helpers.js';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import fs from 'fs';
|
|
7
|
-
import { fileURLToPath } from 'url';
|
|
8
|
-
|
|
9
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
7
|
|
|
11
8
|
const command = getStringArg('--command') as 'approve' | 'init' | 'reference' | 'test' | undefined;
|
|
12
9
|
if (!command) {
|
|
@@ -28,8 +25,7 @@ ${PATCH_END}
|
|
|
28
25
|
`;
|
|
29
26
|
|
|
30
27
|
const packCompare = () => {
|
|
31
|
-
const
|
|
32
|
-
const reportIndex = path.resolve(projectRootDir, 'node_modules/backstopjs/compare/output/index.html');
|
|
28
|
+
const reportIndex = path.resolve(getLibraryPath(), 'node_modules/backstopjs/compare/output/index.html');
|
|
33
29
|
if (fs.existsSync(reportIndex)) {
|
|
34
30
|
let html = fs.readFileSync(reportIndex, 'utf-8');
|
|
35
31
|
const patchStartIndex = html.indexOf(PATCH_START);
|