Skip to content

Commit

Permalink
fix: notify serverless-offline when watched files trigger rebuild (#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
aldenquimby committed Sep 15, 2023
1 parent 6f48e8b commit 20bd3fd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ class EsbuildServerlessPlugin implements ServerlessPlugin {
chokidar.watch(allPatterns, options).on('all', (eventName, srcPath) =>
this.bundle(true)
.then(() => this.updateFile(eventName, srcPath))
.then(() => this.notifyServerlessOffline())
.then(() => this.log.verbose('Watching files for changes...'))
.catch(() => this.log.error('Bundle error, waiting for a file change to reload...'))
);
Expand Down Expand Up @@ -400,6 +401,10 @@ class EsbuildServerlessPlugin implements ServerlessPlugin {
}
}

notifyServerlessOffline() {
this.serverless.pluginManager.spawn('offline:functionsUpdated');
}

async updateFile(op: string, filename: string) {
assertIsString(this.buildDirPath, 'buildDirPath is not a string');

Expand Down

0 comments on commit 20bd3fd

Please sign in to comment.