regressify 1.0.11 → 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.
Files changed (4) hide show
  1. package/README.md +6 -6
  2. package/alias.ps1 +44 -44
  3. package/cli.js +13 -7
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -26,9 +26,9 @@ Please check [Documentation](https://tuyen.blog/optimizely-cms/testing/get-start
26
26
 
27
27
  1. Use new command aliases:
28
28
 
29
- | Command | Alias 1 | Alias 2 | Description |
30
- | --------------------------------------------------- | ------- | ------------- | ------------------- |
31
- | npm run ref -- --test-suite alloy | r alloy | ref alloy | |
32
- | npm run approve -- --test-suite alloy | a alloy | approve alloy | |
33
- | npm run ref -- --test-suite alloy | t alloy | test alloy | |
34
- | npm run ref -- --test-suite sign-in --requiredLogin | t alloy | test alloy | Run with login mode |
29
+ | Command | Alias 1 | Alias 2 | Description |
30
+ | ------------------------------------------------------ | ------- | ------------- | ------------------- |
31
+ | regressify ref -- --test-suite alloy | r alloy | ref alloy | |
32
+ | regressify approve -- --test-suite alloy | a alloy | approve alloy | |
33
+ | regressify ref -- --test-suite alloy | t alloy | test alloy | |
34
+ | regressify ref -- --test-suite sign-in --requiredLogin | t alloy | test alloy | Run with login mode |
package/alias.ps1 CHANGED
@@ -1,44 +1,44 @@
1
- function Approve-TestSuite {
2
- [alias("a")]
3
- [alias("approve")]
4
- param (
5
- # Test suite name
6
- [Parameter(
7
- ValueFromPipeline,
8
- Mandatory)]
9
- [string]
10
- $name
11
- )
12
-
13
- npm run approve -- --test-suite $name
14
- }
15
-
16
- function Reference-TestSuite {
17
- [alias("r")]
18
- [alias("ref")]
19
- param (
20
- # Test suite name
21
- [Parameter(
22
- ValueFromPipeline,
23
- Mandatory)]
24
- [string]
25
- $name
26
- )
27
-
28
- npm run ref -- --test-suite $name
29
- }
30
-
31
- function Test-TestSuite {
32
- [alias("t")]
33
- [alias("test")]
34
- param (
35
- # Test suite name
36
- [Parameter(
37
- ValueFromPipeline,
38
- Mandatory)]
39
- [string]
40
- $name
41
- )
42
-
43
- npm run test -- --test-suite $name
44
- }
1
+ function Approve-TestSuite {
2
+ [alias("a")]
3
+ [alias("approve")]
4
+ param (
5
+ # Test suite name
6
+ [Parameter(
7
+ ValueFromPipeline,
8
+ Mandatory)]
9
+ [string]
10
+ $name
11
+ )
12
+
13
+ regressify approve -- --test-suite $name
14
+ }
15
+
16
+ function Reference-TestSuite {
17
+ [alias("r")]
18
+ [alias("ref")]
19
+ param (
20
+ # Test suite name
21
+ [Parameter(
22
+ ValueFromPipeline,
23
+ Mandatory)]
24
+ [string]
25
+ $name
26
+ )
27
+
28
+ regressify ref -- --test-suite $name
29
+ }
30
+
31
+ function Test-TestSuite {
32
+ [alias("t")]
33
+ [alias("test")]
34
+ param (
35
+ # Test suite name
36
+ [Parameter(
37
+ ValueFromPipeline,
38
+ Mandatory)]
39
+ [string]
40
+ $name
41
+ )
42
+
43
+ regressify test -- --test-suite $name
44
+ }
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 __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
+ 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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "regressify",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "Visual regression tests support",
5
5
  "main": "index.js",
6
6
  "type": "module",