Skip to content

Commit f4ff33d

Browse files
committed
build: add check when running npm install
Even though we're using `yarn` for everything, it's still easy to fall into the old habit of running `npm i` which could mess up the `node_modules` and generate a new lock file. These changes add a script that throws an error when trying to `npm install`, similar to angular/angular.
1 parent d50b9f2 commit f4ff33d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"api": "gulp api-docs",
2525
"breaking-changes": "gulp breaking-changes",
2626
"gulp": "gulp",
27-
"stage-release": "bash ./tools/release/stage-release-bin.sh"
27+
"stage-release": "bash ./tools/release/stage-release-bin.sh",
28+
"preinstall": "node ./tools/npm/check-npm.js"
2829
},
2930
"version": "7.0.2",
3031
"requiredAngularVersion": ">=7.0.0",

tools/npm/check-npm.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
if (process.env.npm_execpath.indexOf('yarn') === -1) {
10+
console.error('Please use Yarn instead of NPM to install dependencies. ' +
11+
'See: https://yarnpkg.com/lang/en/docs/install/');
12+
process.exit(1);
13+
}

0 commit comments

Comments
 (0)