Skip to content

Commit

Permalink
Merge pull request serverless#4145 from medikoo/graceful-fs-packaging
Browse files Browse the repository at this point in the history
Rely on graceful-fs for concurrent file operations (lambda packaging)
  • Loading branch information
pmuens authored Aug 24, 2017
2 parents 380a6c1 + e5f4a60 commit 0399497
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 61 deletions.
9 changes: 3 additions & 6 deletions lib/plugins/package/lib/zipService.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@ const archiver = require('archiver');
const os = require('os');
const path = require('path');
const crypto = require('crypto');
const fs = BbPromise.promisifyAll(require('fs'));
const fs = BbPromise.promisifyAll(require('graceful-fs'));
const childProcess = BbPromise.promisifyAll(require('child_process'));
const globby = require('globby');
const _ = require('lodash');

const fsStat = BbPromise.promisify(fs.stat);
const fsReadFile = BbPromise.promisify(fs.readFile);

module.exports = {
zipService(exclude, include, zipFileName) {
const params = {
Expand Down Expand Up @@ -89,7 +86,7 @@ module.exports = {
filePath
);

return fsStat(fullPath).then(stats =>
return fs.statAsync(fullPath).then(stats =>
this.getFileContent(fullPath).then(fileContent =>
zip.append(fileContent, {
name: filePath,
Expand All @@ -104,7 +101,7 @@ module.exports = {
},

getFileContent(fullPath) {
return fsReadFile(fullPath, 'utf8');
return fs.readFileAsync(fullPath, 'utf8');
},
};

Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/package/lib/zipService.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const JsZip = require('jszip');
const globby = require('globby');
const _ = require('lodash');
const BbPromise = require('bluebird');
const fs = BbPromise.promisifyAll(require('fs'));
const fs = BbPromise.promisifyAll(require('graceful-fs'));
const childProcess = BbPromise.promisifyAll(require('child_process'));
const sinon = require('sinon');
const Package = require('../package');
Expand Down
116 changes: 62 additions & 54 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"fs-extra": "^0.26.7",
"get-stdin": "^5.0.1",
"globby": "^6.1.0",
"graceful-fs": "^4.1.11",
"graphql": "^0.10.1",
"graphql-tag": "^2.4.0",
"https-proxy-agent": "^1.0.0",
Expand Down

0 comments on commit 0399497

Please sign in to comment.