Skip to content

Commit

Permalink
Build/Test Tools: Introduce Install-changed. It keeps a hash of `pack…
Browse files Browse the repository at this point in the history
…age.json` and compares it when run. If it has any changes, it runs `npm install`.

This keeps `node_modules` always updated and is useful not only when the packages have been updated, but also when the working copy has been "reverted" to an earlier revision.

Fixes #49594.

git-svn-id: https://develop.svn.wordpress.org/trunk@47497 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
azaozz committed Mar 24, 2020
1 parent 679fbbc commit 41027e3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ wp-tests-config.php
/src/wp-includes/css/dist
/src/wp-includes/css/*.min.css
/src/wp-includes/css/*-rtl.css
/packagehash.txt

# Files and folders that get created in wp-content
/src/wp-content/blogs.dir
Expand Down
4 changes: 4 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* jshint esversion: 6 */
/* globals Set */
var webpackConfig = require( './webpack.config' );
var installChanged = require( 'install-changed' );

module.exports = function(grunt) {
var path = require('path'),
Expand Down Expand Up @@ -41,6 +42,9 @@ module.exports = function(grunt) {
);
}

// First do `npm install` if package.json has changed.
installChanged.watchPackage();

// Load tasks.
require('matchdep').filterDev(['grunt-*', '!grunt-legacy-util']).forEach( grunt.loadNpmTasks );
// Load legacy utils.
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"grunt-sass": "~3.1.0",
"grunt-webpack": "^3.1.3",
"ink-docstrap": "1.3.2",
"install-changed": "1.1.0",
"jquery-migrate": "1.4.1",
"matchdep": "~2.0.0",
"node-sass": "~4.13.1",
Expand Down

0 comments on commit 41027e3

Please sign in to comment.