Skip to content
Open
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
34 changes: 20 additions & 14 deletions lib/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const ar = require('ar-async'),
mkdirp = require('mkdirp'),
log = require('npmlog'),
path = require('path'),
rimraf = require('rimraf'),
rimraf = require('rimraf').rimraf,
shelljs = require('shelljs'),
stripbom = require('strip-bom'),
temp = require('temp'),
Expand Down Expand Up @@ -135,7 +135,7 @@ const appdata = commonTools.appdata;

if (options && Object.prototype.hasOwnProperty.call(options, 'remainPlainIPK')) {
this.remainPlainIPK = options.remainPlainIPK;
}
}

if (options && Object.prototype.hasOwnProperty.call(options, 'sign')) {
if (!fs.existsSync(path.resolve(options.sign))) {
Expand Down Expand Up @@ -474,10 +474,13 @@ const appdata = commonTools.appdata;

function _removeTmpDir(next) {
log.info("package#analyzeIPK()#_removeTmpDir()");
rimraf(tmpDirPath, function(err) {
log.verbose("package#analyzeIPK()#_removeTmpDir()", "removed " + tmpDirPath);
next(err);
});
rimraf(tmpDirPath).then(() => {
log.verbose(
"package#analyzeIPK()#_removeTmpDir()",
"removed " + tmpDirPath,
);
next();
}, next);
}
}
};
Expand Down Expand Up @@ -1013,7 +1016,7 @@ const appdata = commonTools.appdata;
}
}

function _checkAppinfo(file, next) {
function _checkAppinfo(file, next) {
let source;
if (path.resolve(file) === path.normalize(file)) {
return next(errHndl.getErrMsg("NOT_RELATIVE_PATH_APPINFO", file));
Expand Down Expand Up @@ -1499,14 +1502,14 @@ const appdata = commonTools.appdata;
setImmediate(next, err);
return;
}

// Gets hash from control
let controlSigner = crypto.createSign('sha256')
controlSigner.update(controlData);
controlSigner.end();
const controlSign = controlSigner.sign(privateKey);
let base64data = Buffer.from(controlSign).toString('base64');

fs.writeFile(controlSignFilePath, base64data, next);
});
} catch (err) {
Expand Down Expand Up @@ -1590,7 +1593,7 @@ const appdata = commonTools.appdata;
if (entry.gid > 0o7777777) {
entry.gid = 0;
}

return true;
};

Expand Down Expand Up @@ -1702,10 +1705,13 @@ const appdata = commonTools.appdata;
middleCb("Skipping removal of " + this.tempDir);
setImmediate(next);
} else {
rimraf(this.tempDir, function(err) {
log.verbose("package#cleanupTmpDir()", "removed " + this.tempDir);
setImmediate(next, err);
}.bind(this));
rimraf(this.tempDir).then(
() => {
log.verbose("package#cleanupTmpDir()", "removed " + this.tempDir);
setImmediate(next);
},
(err) => setImmediate(next, err),
);
}
}

Expand Down