Skip to content

Commit

Permalink
Fix: problem due to NW.js 0.22.0+ symlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-lynch committed May 16, 2017
1 parent a9ed78b commit 7f10751
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
38 changes: 18 additions & 20 deletions lib/downloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var temp = require('temp');
var DecompressZip = require('decompress-zip');
var ncp = require('graceful-ncp').ncp;
var rimraf = require('rimraf');
var extract = require('extract-zip');

// Automatically track and cleanup files at exit
temp.track();
Expand Down Expand Up @@ -134,30 +135,27 @@ module.exports = {
var files = [],
done = Promise.defer();

new DecompressZip(zipfile)
.on('error', function(err){
done.reject(err);
})
.on('extract', function(log) {
// Setup chmodSync to fix permissions
files.forEach(function(file) {
fs.chmodSync(path.join(destination, file.path), file.mode);
});
var onEntry = function(entry){
files.push({
mode: entry.externalFileAttributes >>> 16,
path: entry.fileName
});
};

done.resolve({files:files, destination:destination});
})
.extract({
path: destination,
filter: function(entry) {
files.push({
path: entry.path,
mode: entry.mode.toString(8)
});
extract(zipfile, { dir: destination, onEntry: onEntry }, function(err){
if(err){
return done.reject(err);
}

return true;
}

// Setup chmodSync to fix permissions
files.forEach(function(file) {
fs.chmodSync(path.join(destination, file.path), file.mode);
});

done.resolve({ files: files, destination: destination });
});

return done.promise;
},
stripRootFolder: function(extracted){
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"application"
],
"devDependencies": {
"decompress-zip": "0.3.0",
"eol": "~0.6.0",
"nock": "^9.0.5",
"tape": "~4.6.2",
Expand All @@ -46,8 +47,8 @@
"dependencies": {
"archiver": "^1.3.0",
"bluebird": "^3.4.0",
"decompress-zip": "0.3.0",
"deprecate": "~1.0.0",
"extract-zip": "^1.6.5",
"graceful-fs-extra": "^2.0.0",
"graceful-ncp": "^3.0.0",
"inherits": "~2.0.1",
Expand All @@ -68,4 +69,3 @@
"winresourcer": "^0.9.0"
}
}

1 comment on commit 7f10751

@fritx
Copy link

@fritx fritx commented on 7f10751 May 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.