Build/Test Tools: Introduce Install-changed. It keeps a hash of `package.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
This commit is contained in:
Andrew Ozz 2020-03-24 01:04:43 +00:00
parent 679fbbc422
commit 41027e3f8e
4 changed files with 12 additions and 0 deletions

1
.gitignore vendored
View File

@ -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

View File

@ -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'),
@ -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.

6
package-lock.json generated
View File

@ -11784,6 +11784,12 @@
}
}
},
"install-changed": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/install-changed/-/install-changed-1.1.0.tgz",
"integrity": "sha512-APUWMdQnwGcyv9bmuvgxCcrR6qtD996+hofEEAPGSjsvGIZuBpBF0yrYAKOl9tmhm2AzxJC4EXUbxZ/SId4NIA==",
"dev": true
},
"internal-ip": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/internal-ip/-/internal-ip-4.3.0.tgz",

View File

@ -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",