1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Add start script to default project package

This commit is contained in:
Dave Conway-Jones 2018-04-05 11:30:16 +01:00
parent 838c7a5e89
commit 499d22daca
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
3 changed files with 15 additions and 4 deletions

View File

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

View File

@ -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" ;}
}

View File

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