turbo-ignore 0.0.13 → 0.0.16

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/index.js +16 -7
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -6,9 +6,10 @@ const path = require('path');
6
6
  const { getWorkspaceRoot } = require('workspace-tools');
7
7
 
8
8
  const root = getRoot();
9
-
9
+ const scope = getScope();
10
+ const command = `npx turbo@canary run build --scope=${scope} --since=HEAD^ --dry=json`;
10
11
  exec(
11
- `npx turbo@canary run build --scope=${getScope()} --since=HEAD^ --dry=json`,
12
+ command,
12
13
  {
13
14
  cwd: root,
14
15
  },
@@ -19,10 +20,14 @@ exec(
19
20
  }
20
21
 
21
22
  const { packages } = JSON.parse(stdout);
22
- console.log('≫ Using turbo to determine affected packages...');
23
23
  console.log(
24
- `≫ Analyzing results of \`turbo run build --scope=${process.argv[2]} --since=HEAD^ --dry=json\``
24
+ '≫ Using Turborepo to determine if this project is affected by the commit...'
25
25
  );
26
+ console.log(`≫ Analyzing results of \`${command}\`...`);
27
+ if (!packages.length) {
28
+ console.error();
29
+ process.exit(1);
30
+ }
26
31
  if (packages.length > 0) {
27
32
  console.log(
28
33
  `≫ Found ${packages.length} packages affected by this commit:`
@@ -66,11 +71,12 @@ function searchUp(pathName, cwd) {
66
71
  }
67
72
 
68
73
  function getScope() {
69
- if (process.argv[2] != null) {
74
+ if (process.argv.length > 1 && process.argv[2] != null) {
70
75
  return process.argv[2];
71
76
  }
72
77
  const raw = fs.readFileSync(path.join(process.cwd(), 'package.json'), 'utf8');
73
78
  const pkgJSON = JSON.parse(raw);
79
+ console.log(`≫ Inferred \`${pkgJSON.name}\` as scope from "./package.json"`);
74
80
  return pkgJSON.name;
75
81
  }
76
82
 
@@ -80,8 +86,11 @@ function getRoot() {
80
86
  if (!root) {
81
87
  root = getWorkspaceRoot(process.cwd());
82
88
  if (!root) {
83
- console.error('Error: workspace root not found.');
84
- process.exit(0);
89
+ console.error(
90
+ 'Error: workspace root not found. turbo-ignore inferencing failed, proceeding with build.'
91
+ );
92
+ console.error('');
93
+ process.exit(1);
85
94
  }
86
95
  }
87
96
  return root;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turbo-ignore",
3
- "version": "0.0.13",
3
+ "version": "0.0.16",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": "index.js",