Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functionality to install modules during init #233

Merged
merged 4 commits into from
Mar 10, 2023

Conversation

Luke-Roy-IBM
Copy link
Member

Install modules specified in package.json during initialisation as a alternative to packageing them. Detect if the node_modules directory is missing and installes the node modules.

Install modules specified in package.json during initialisation as a alternative to packageing them.
Detect if the node_modules directory is  missing and installes the node modules.
@@ -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.

@Luke-Roy-IBM Luke-Roy-IBM requested a review from style95 March 10, 2023 11:05
Copy link
Member

@style95 style95 left a comment

Choose a reason for hiding this comment

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

LGTM

@Luke-Roy-IBM Luke-Roy-IBM merged commit baa4185 into apache:master Mar 10, 2023
@Luke-Roy-IBM
Copy link
Member Author

Simple example that shows how the new functionality works

index.js

function main(args) {
	const oneLinerJoke = require('./one-liner-joke');
	let getRandomJoke = oneLinerJoke.getRandomJoke();

	return {
        	body: getRandomJoke.body
    	}
}


module.exports.main = main;

package.json

{
	"name": "my-action",
	"main": "index.js",
	"dependencies" : {
		"one-liner-joke" : "1.2.2"
 	}
}

msciabarra pushed a commit to nuvolaris/openwhisk-runtime-nodejs that referenced this pull request Apr 6, 2023
* Add functionality to install modules during init

Install modules specified in package.json during initialisation as a alternative to packageing them.
Detect if the node_modules directory is  missing and installes the node modules.

* check if package.json has dependencies and install if required

* remove trailing whitespace

* read package.json correctly as object
@Luke-Roy-IBM Luke-Roy-IBM deleted the init-npm branch June 21, 2023 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants