Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Opt in to use locally installed Azure Functions Core Tools, instead of node_modules/.bin tools. #667

Open
BartInTheField opened this issue May 19, 2023 · 0 comments

Comments

@BartInTheField
Copy link

This is a Feature Proposal

Description

Right now in the utils used for sls offline, node_modules/.bin of the serverless instance it self are used to spawn azure functions. As a user I would like to opt in to use self installed Azure Functions Core Tools, in practice this means just running func.

Why?

In the case of using a monorepo like NX or Lerna, node_modules are stored in the root of a project. The current implementation searches for azure functions tools in a path that does not exist in these monorepo's.

Also, when the user has worked previously with Azure Functions Core Tools or also uses Azure functions outside of serverless, it would be beneficial to used there own locally installed tools.

How?

I have written my own patch to support this behaviour. But it would be better to have some command line arguments to opt in to this behaviour without writing a patch.

--- a/node_modules/serverless-azure-functions/lib/shared/utils.js
+++ b/node_modules/serverless-azure-functions/lib/shared/utils.js
@@ -282,8 +282,7 @@ var Utils = /** @class */ (function () {
      */
     Utils.spawnLocal = function (options) {
         var serverless = options.serverless, command = options.command;
-        var localCommand = path_1.join(serverless.config.servicePath, "node_modules", ".bin", command);
-        return this.spawn(__assign({}, options, { command: localCommand, commandName: command }));
+        return this.spawn(__assign({}, options, { commandName: command }));
     };
     // public static spawn()
     Utils.spawn = function (options) {
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant