pm2-deploy
Advanced tools
Comparing version 0.3.10 to 0.4.0
@@ -15,3 +15,7 @@ var fs = require('fs'); | ||
function spawn(hostJSON, args, cb) { | ||
var shellSyntaxCommand = "echo '" + hostJSON + "' | \"" + __dirname.replace(/\\/g, '/') + "/deploy\" " + args.join(' '); | ||
var shellSyntaxCommand = "echo '" + hostJSON + "' | \"" + __dirname.replace(/\\/g, '/') + "/deploy\" " | ||
if (args.length > 0) | ||
shellSyntaxCommand += '"' + args.join('" "') + '"'; | ||
var proc = childProcess.spawn('sh', ['-c', shellSyntaxCommand], { stdio: 'inherit' }); | ||
@@ -26,3 +30,5 @@ var error; | ||
if (code == 0) return cb(null, args); | ||
else return cb(error || code); | ||
else { | ||
return cb(error || code); | ||
} | ||
}); | ||
@@ -90,2 +96,5 @@ } | ||
var originalPostDeploy = typeof target_conf['post-deploy'] === 'string' | ||
? target_conf['post-deploy'] | ||
: ''; | ||
if (Array.isArray(target_conf.host)) { | ||
@@ -100,6 +109,8 @@ series(target_conf.host.reduce(function (jobs, host) { | ||
target_conf.host = host; | ||
target_conf['post-deploy'] = 'export ' + objectToEnvVars(target_conf.env) + ' && ' + target_conf['post-deploy'] | ||
var custom_data = JSON.stringify(target_conf); | ||
target_conf['post-deploy'] = prependEnvVars( | ||
originalPostDeploy, | ||
objectToEnvVars(target_conf.env) | ||
); | ||
spawn(custom_data, args, done); | ||
spawn(JSON.stringify(target_conf), args, done); | ||
}); | ||
@@ -114,3 +125,7 @@ return jobs; | ||
target_conf['post-deploy'] = 'export ' + objectToEnvVars(target_conf.env) + ' && ' + target_conf['post-deploy'] | ||
target_conf['post-deploy'] = prependEnvVars( | ||
originalPostDeploy, | ||
objectToEnvVars(target_conf.env) | ||
); | ||
spawn(JSON.stringify(target_conf), args, cb); | ||
@@ -128,16 +143,8 @@ } | ||
function run() { | ||
var conf = JSON.parse(fs.readFileSync('app.json')); | ||
var args = process.argv; | ||
if (args.indexOf('deploy') == -1) | ||
throw new Error('deploy argument not found'); | ||
args.splice(0, args.indexOf('deploy') + 1); | ||
var env = args[0]; | ||
deployForEnv(conf.deploy, env, args, function (err, data) { | ||
console.log(arguments); | ||
}); | ||
/** | ||
* @param {string} cmd | ||
* @param {string} envVars | ||
*/ | ||
function prependEnvVars(cmd, envVars) { | ||
return (envVars && 'export ' + envVars + (cmd && ' && ')) + cmd; | ||
} | ||
@@ -148,5 +155,1 @@ | ||
}; | ||
if (require.main === module) { | ||
run(); | ||
} |
{ | ||
"name": "pm2-deploy", | ||
"version": "0.3.10", | ||
"version": "0.4.0", | ||
"description": "Deployment system for PM2", | ||
"main": "deploy.js", | ||
"engines": { | ||
"node": ">=4.0.0" | ||
}, | ||
"repository": { | ||
@@ -11,3 +14,3 @@ "type": "git", | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "mocha --exit" | ||
}, | ||
@@ -20,3 +23,3 @@ "dependencies": { | ||
"better-assert": "^1.0.0", | ||
"mocha": "^3.5", | ||
"mocha": "^5.2", | ||
"should": "^13" | ||
@@ -23,0 +26,0 @@ }, |
@@ -7,2 +7,2 @@ | ||
[![NPM version](https://badge.fury.io/js/pm2-deploy.png)](http://badge.fury.io/js/pm2) | ||
[![Build Status](https://api.travis-ci.org/Unitech/pm2-deploy.png?branch=master)](https://travis-ci.org/Unitech/PM2) | ||
[![Build Status](https://api.travis-ci.org/Unitech/pm2-deploy.png?branch=master)](https://travis-ci.org/Unitech/pm2-deploy) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15214
154
5