From 105d1a5bc813094af820a878da7bc1ec22a18983 Mon Sep 17 00:00:00 2001 From: Gal Bashan Date: Wed, 24 Jun 2020 18:30:06 +0300 Subject: [PATCH] feat(commands): adding run command (#21) --- index.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 7434aac..d520c9a 100644 --- a/index.js +++ b/index.js @@ -13,6 +13,19 @@ class PackageExternal { this.symlinked = false; + this.commands = { + packageExternal: { + usage: 'create external package symlinks', + lifecycleEvents: ['run'], + commands: { + run: { + usage: 'remove symlinks', + lifecycleEvents: ['init'], + }, + }, + }, + }; + this.hooks = { 'before:package:createDeploymentArtifacts': this.beforeDeploy.bind(this), 'before:deploy:function:packageFunction': this.beforeDeploy.bind(this), @@ -21,7 +34,8 @@ class PackageExternal { "before:offline:start:init": this.beforeDeploy.bind(this), "before:offline:start:end": this.afterDeploy.bind(this), "invoke:local:loadEnvVars": this.beforeDeploy.bind(this), - "invoke:local:invoke": this.afterDeploy.bind(this) + "invoke:local:invoke": this.afterDeploy.bind(this), + "packageExternal:run:init": this.beforeDeploy.bind(this), }; this.handleExit(); @@ -40,6 +54,7 @@ class PackageExternal { afterDeploy() { if(this.symlinked) { + this.serverless.cli.log(`[serverless-package-external] cleaning up`); this.options.external.forEach(externalFolder => { const target = path.basename(externalFolder); symlink.removeFolder(target);