Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions 27 lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ Lambda.prototype._fileCopy = (program, src, dest, excludeNodeModules, callback)
})
}

Lambda.prototype._npmInstall = (program, codeDirectory, callback) => {
Lambda.prototype._npmInstall = (program, codeDirectory) => {
const dockerBaseOptions = [
'run', '--rm', '-v', `${codeDirectory}:/var/task`,
program.dockerImage,
Expand Down Expand Up @@ -338,15 +338,14 @@ Lambda.prototype._npmInstall = (program, codeDirectory, callback) => {
}
})()

execFile(params.command, params.options, {
maxBuffer: maxBufferSize,
env: process.env
}, (err) => {
if (err) {
return callback(err)
}

return callback(null, true)
return new Promise((resolve, reject) => {
execFile(params.command, params.options, {
maxBuffer: maxBufferSize,
env: process.env
}, (err) => {
if (err) return reject(err)
resolve()
})
})
}

Expand Down Expand Up @@ -532,11 +531,7 @@ Lambda.prototype._buildAndArchive = function (program, archiveCallback) {
return archiveCallback(err)
}
console.log('=> Running npm install --production')
_this._npmInstall(program, codeDirectory, (err) => {
if (err) {
return archiveCallback(err)
}

_this._npmInstall(program, codeDirectory).then(() => {
_this._postInstallScript(program, codeDirectory, (err) => {
if (err) {
return archiveCallback(err)
Expand All @@ -545,6 +540,8 @@ Lambda.prototype._buildAndArchive = function (program, archiveCallback) {
console.log('=> Zipping deployment package')
_this._zip(program, codeDirectory, archiveCallback)
})
}).catch((err) => {
return archiveCallback(err)
})
})
}).catch((err) => {
Expand Down
23 changes: 9 additions & 14 deletions 23 test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,14 +392,12 @@ describe('lib/main', function () {
})
})

it('_npm adds node_modules', function (done) {
it('_npm adds node_modules', function () {
_timeout({ this: this, sec: 30 }) // give it time to build the node modules

lambda._npmInstall(program, codeDirectory, (err, result) => {
assert.isNull(err)
return lambda._npmInstall(program, codeDirectory).then(() => {
const contents = fs.readdirSync(codeDirectory)
assert.include(contents, 'node_modules')
done()
})
})
})
Expand Down Expand Up @@ -428,14 +426,12 @@ describe('lib/main', function () {
codeDirectory = lambda._codeDirectory()
})

it('_npm adds node_modules', function (done) {
it('_npm adds node_modules', function () {
_timeout({ this: this, sec: 30 }) // give it time to build the node modules

lambda._npmInstall(program, codeDirectory, (err, result) => {
assert.isNull(err)
return lambda._npmInstall(program, codeDirectory).then(() => {
const contents = fs.readdirSync(codeDirectory)
assert.include(contents, 'node_modules')
done()
})
})
})
Expand Down Expand Up @@ -507,19 +503,18 @@ describe('lib/main', function () {
})
})

describe('_zip', function () {
describe('_zip', () => {
beforeEach(function (done) {
_timeout({ this: this, sec: 30 }) // give it time to build the node modules
lambda._cleanDirectory(codeDirectory).then(() => {
lambda._fileCopy(program, '.', codeDirectory, true, function (err) {
lambda._fileCopy(program, '.', codeDirectory, true, (err) => {
if (err) {
return done(err)
}
lambda._npmInstall(program, codeDirectory, function (err) {
if (err) {
return done(err)
}
lambda._npmInstall(program, codeDirectory).then(() => {
done()
}).catch((err) => {
done(err)
})
})
}).catch((err) => {
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.