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
11 changes: 11 additions & 0 deletions core/nodejsActionBase/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ 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
Copy link
Member

@style95 style95 Mar 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice!
I want to let this in but unsure if there would be no side effect.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my tests so far the current functionality is not impacted

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No edge case comes up in my mind too.

// 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