mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Create a package.json file in userDir if one doesn't exist
This commit is contained in:
parent
829087550d
commit
85b2a03a42
@ -768,6 +768,7 @@ RED.palette.editor = (function() {
|
||||
e.preventDefault();
|
||||
if (!$(this).hasClass('disabled')) {
|
||||
$("#palette-module-install-confirm").data('module',entry.id);
|
||||
$("#palette-module-install-confirm").data('version',entry.version);
|
||||
$("#palette-module-install-confirm").data('url',entry.url);
|
||||
$("#palette-module-install-confirm").data('shade',shade);
|
||||
$("#palette-module-install-confirm-body").html(RED._("palette.editor.confirm.install.body"));
|
||||
@ -822,8 +823,9 @@ RED.palette.editor = (function() {
|
||||
class: "primary palette-module-install-confirm-button-install",
|
||||
click: function() {
|
||||
var id = $(this).data('module');
|
||||
var version = $(this).data('version');
|
||||
var shade = $(this).data('shade');
|
||||
installNodeModule(id,shade,function(xhr) {
|
||||
installNodeModule(id,version,shade,function(xhr) {
|
||||
if (xhr) {
|
||||
if (xhr.responseJSON) {
|
||||
RED.notify(RED._('palette.editor.errors.installFailed',{module: id,message:xhr.responseJSON.message}));
|
||||
|
@ -99,7 +99,7 @@ function installModule(module,version) {
|
||||
}
|
||||
|
||||
var installDir = settings.userDir || process.env.NODE_RED_HOME || ".";
|
||||
var child = child_process.execFile(npmCommand,['install','--production',installName],
|
||||
var child = child_process.execFile(npmCommand,['install','--save','--save-exact','--production',installName],
|
||||
{
|
||||
cwd: installDir
|
||||
},
|
||||
@ -186,7 +186,7 @@ function uninstallModule(module) {
|
||||
|
||||
var list = registry.removeModule(module);
|
||||
log.info(log._("server.install.uninstalling",{name:module}));
|
||||
var child = child_process.execFile(npmCommand,['remove',module],
|
||||
var child = child_process.execFile(npmCommand,['remove','--save',module],
|
||||
{
|
||||
cwd: installDir
|
||||
},
|
||||
|
@ -230,8 +230,20 @@ var localfilesystem = {
|
||||
|
||||
globalSettingsFile = fspath.join(settings.userDir,".config.json");
|
||||
|
||||
var packageFile = fspath.join(settings.userDir,"package.json");
|
||||
|
||||
if (!settings.readOnly) {
|
||||
promises.push(promiseDir(libFlowsDir));
|
||||
try {
|
||||
fs.statSync(packageFile);
|
||||
} catch(err) {
|
||||
var defaultPackage = {
|
||||
"name": "node-red-project",
|
||||
"description": "A Node-RED Project",
|
||||
"version": "0.0.1"
|
||||
};
|
||||
promises.push(writeFile(packageFile,JSON.stringify(defaultPackage,"",4)));
|
||||
}
|
||||
}
|
||||
|
||||
return when.all(promises);
|
||||
|
Loading…
Reference in New Issue
Block a user