forked from botbits/lambda-bin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
39 lines (33 loc) · 1.13 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* eslint-env node */
'use strict';
const path = require('path');
const RuntimeBin = require ('bin-minify/lib/RuntimeBin');
class LambdaBin {
constructor (options) {
options = undefined !== options ? options : {};
options.useSymlinks = true;
options.targetPath = options.targetPath || path.resolve(__dirname, path.join('bin', 'bin-minify'));
this.targetPath = options.targetPath;
this.runtimeBin = new RuntimeBin(options);
}
applyMinPack (fromBase) {
return this.runtimeBin.applyMinPack(fromBase);
}
setPath (pathsToAdd) {
// see https://docs.aws.amazon.com/lambda/latest/dg/nodejs-create-deployment-pkg.html
if (!Array.isArray(pathsToAdd)) pathsToAdd = [pathsToAdd];
process.env.PATH = pathsToAdd.concat([
process.env.PATH,
process.env.LAMBDA_TASK_ROOT,
]).join(':');
return process.env.PATH;
}
setEnv (variablesToSet, shouldOverwrite) {
for (var envVar in variablesToSet) {
process.env[envVar] = (!shouldOverwrite && process.env[envVar])
? `${process.env[envVar]}:${variablesToSet[envVar]}`
: variablesToSet[envVar];
}
}
}
module.exports = LambdaBin;