Upgrade to latest nodemon to fix restart

The grunt-nodemon module we were using is no longer
maintained and is stuck on a 1.x version of nodemon.

At that version, node-red doesn't restart properly
due to our increased signal handling in the core.

This change removes grunt-nodemon and replaces it
with nodemon itself, with a custom task to wrap it
that does the same work as grunt-nodemon was doing.
This commit is contained in:
Nick O'Leary 2020-09-29 12:11:10 +01:00
parent b595e84c30
commit 952c9d8bdb
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
3 changed files with 22 additions and 3 deletions

View File

@ -36,6 +36,7 @@ Runtime
- Skip loading node html if disableEditor set #2684
- Update util.writeFile to write to tmp file before rename #2683
- Fix getModuleFiles function to include path property #2705 (@t-kawamorita)
- Update nodemon to latest so grunt dev task behaves
Nodes

View File

@ -20,7 +20,7 @@ var sass = require("node-sass");
module.exports = function(grunt) {
var nodemonArgs = ["-v"];
var nodemonArgs = ["-V"];
var flowFile = grunt.option('flowFile');
if (flowFile) {
nodemonArgs.push(flowFile);
@ -507,7 +507,6 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-chmod');
@ -521,6 +520,25 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-npm-command');
grunt.loadNpmTasks('grunt-mkdir');
grunt.registerMultiTask('nodemon', 'Runs a nodemon monitor of your node.js server.', function () {
const nodemon = require('nodemon');
this.async();
const options = this.options();
options.script = this.data.script;
let callback;
if (options.callback) {
callback = options.callback;
delete options.callback;
} else {
callback = function(nodemonApp) {
nodemonApp.on('log', function (event) {
console.log(event.colour);
});
};
}
callback(nodemon(options));
});
grunt.registerMultiTask('attachCopyright', function() {
var files = this.data.src;
var copyright = "/**\n"+

View File

@ -99,7 +99,6 @@
"grunt-jsonlint": "2.1.3",
"grunt-mkdir": "~1.0.0",
"grunt-mocha-istanbul": "5.0.2",
"grunt-nodemon": "~0.4.2",
"grunt-npm-command": "~0.1.2",
"grunt-sass": "~3.1.0",
"grunt-simple-mocha": "~0.4.1",
@ -112,6 +111,7 @@
"mosca": "^2.8.3",
"node-red-node-test-helper": "^0.2.5",
"node-sass": "^4.14.1",
"nodemon": "2.0.4",
"should": "13.2.3",
"sinon": "1.17.7",
"stoppable": "^1.1.0",