This repository has been archived by the owner on Apr 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: bundle lambdas in script instead of command line (#655)
- Loading branch information
1 parent
b308d2a
commit d6d3e00
Showing
6 changed files
with
72 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,26 @@ | ||
path = require('path'); | ||
esbuild = require('esbuild'); | ||
var fs = require('fs'); | ||
var fse = require('fs-extra'); | ||
var path = require('path'); | ||
|
||
esbuild.build({ | ||
entryPoints: [path.join(__dirname, '../../src/index.ts')], | ||
bundle: true, | ||
platform: 'node', | ||
target: 'node14', | ||
external: ['aws-sdk'], | ||
outfile: path.join(__dirname, '../index.js'), | ||
}).catch(() => process.exit(1)); | ||
// expected usage: `node build_lambda.js <path> <path> <pathToFile> <fileName>` | ||
// for use with NodeJsFunction command hooks to add files to Lambda functions, | ||
// so <path> <path> will usually be the inputDir and outputDir variables, respectively | ||
var inputDir = process.argv[2]; | ||
var outputDir = process.argv[3]; | ||
var fileToMove = process.argv[4]; | ||
var isDirectory = process.argv.length > 5 ? true : false; | ||
|
||
function ensureDirectoryExistence(filePath) { | ||
var dirname = path.dirname(filePath); | ||
if (fs.existsSync(dirname)) { | ||
return true; | ||
} | ||
fs.mkdirSync(dirname, { recursive: true }); | ||
} | ||
|
||
if (isDirectory) { | ||
fse.copySync(inputDir, outputDir); | ||
} else { | ||
ensureDirectoryExistence(`${outputDir}\\${fileToMove}`); | ||
fs.copyFileSync(`${inputDir}\\${fileToMove}`, `${outputDir}\\${fileToMove}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters