Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions core/nodejsActionBase/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,25 @@ function initializeActionHandler(message) {
return Promise.reject('Zipped actions must contain either package.json or index.js at the root.');
}

// install npm modules during init if source code zip doesn´t containt them
// check if package.json exists and node_modules don`t
if (fs.existsSync('package.json') && !fs.existsSync('./node_modules/')) {
var package_json = JSON.parse(fs.readFileSync('package.json', 'utf8'));
if (package_json.hasOwnProperty('dependencies')) {
if (Object.keys(package_json.dependencies).length > 0) {
exec("npm install")

// check environment variable OW_ENABLE_INIT_INSTALL if we should do a 'npm install' to load not yet installed modules.
let enableInitInstall= !process.env.OW_ENABLE_INIT_INSTALL ? 'true' : process.env.OW_ENABLE_INIT_INSTALL;

if (enableInitInstall === 'true') {
// install npm modules during init if source code zip doesn´t containt them
// check if package.json exists and node_modules don`t
if (fs.existsSync('package.json') && !fs.existsSync('./node_modules/')) {
var package_json = JSON.parse(fs.readFileSync('package.json', 'utf8'));
if (package_json.hasOwnProperty('dependencies')) {
if (Object.keys(package_json.dependencies).length > 0) {
exec("npm install")
}
}
}
}



// The module to require.
let whatToRequire = index !== undefined ? path.join(moduleDir, index) : moduleDir;
let handler = eval('require("' + whatToRequire + '").' + main);
Expand Down