diff --git a/red/runtime/storage/localfilesystem/projects/Project.js b/red/runtime/storage/localfilesystem/projects/Project.js index aa2693001..11aa32564 100644 --- a/red/runtime/storage/localfilesystem/projects/Project.js +++ b/red/runtime/storage/localfilesystem/projects/Project.js @@ -279,6 +279,11 @@ Project.prototype.update = function (user, data) { if (data.hasOwnProperty('dependencies')) { savePackage = true; this.package.dependencies = data.dependencies; + if (this.package.dependencies.hasOwnProperty("node-red")) { + this.package.scripts = {"start":"node node_modules/node-red/red.js -u . " + this.package['node-red'].settings.flowFile}; + } else { + delete(this.package.scripts.start); + } } if (data.hasOwnProperty('summary')) { savePackage = true; @@ -332,6 +337,11 @@ Project.prototype.update = function (user, data) { if (data.files.hasOwnProperty('flow') && this.package['node-red'].settings.flowFile !== data.files.flow) { this.paths.flowFile = data.files.flow; this.package['node-red'].settings.flowFile = data.files.flow; + if (this.package.dependencies.hasOwnProperty("node-red")) { + this.package.scripts = {"start":"node node_modules/node-red/red.js -u . " + data.files.flow}; + } else { + delete(this.package.scripts.start); + } savePackage = true; flowFilesChanged = true; } diff --git a/red/runtime/storage/localfilesystem/projects/defaultFileSet.js b/red/runtime/storage/localfilesystem/projects/defaultFileSet.js index 12368ec75..768b0e2fd 100644 --- a/red/runtime/storage/localfilesystem/projects/defaultFileSet.js +++ b/red/runtime/storage/localfilesystem/projects/defaultFileSet.js @@ -24,7 +24,8 @@ module.exports = { "node-red": { "settings": { } - } + }, + "scripts": {} }; if (project.files) { if (project.files.flow) { @@ -43,5 +44,5 @@ module.exports = { return content; }, - ".gitignore": function() { return "*.backup" ;} + ".gitignore": function() { return "*.backup\n" ;} } diff --git a/red/runtime/storage/localfilesystem/util.js b/red/runtime/storage/localfilesystem/util.js index 6fb75d255..422a06946 100644 --- a/red/runtime/storage/localfilesystem/util.js +++ b/red/runtime/storage/localfilesystem/util.js @@ -81,8 +81,8 @@ module.exports = { writeFile: function(path,content,backupPath) { if (backupPath) { try { - console.log(path); - console.log(backupPath); + // console.log(path); + // console.log(backupPath); fs.renameSync(path,backupPath); } catch(err) { console.log(err);