mirror of https://github.com/keeweb/keeweb.git
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
module.exports = function (grunt) {
|
|
grunt.registerMultiTask('nsis', 'Launches NSIS installer', function () {
|
|
const done = this.async();
|
|
const opt = this.options();
|
|
const args = [];
|
|
const win = process.platform === 'win32';
|
|
const prefix = win ? '/' : '-';
|
|
Object.keys(opt.vars).forEach(key => {
|
|
let value = opt.vars[key];
|
|
if (typeof value === 'function') {
|
|
value = value();
|
|
}
|
|
if (value) {
|
|
args.push(`${prefix}D${key}=${value}`);
|
|
}
|
|
});
|
|
args.push(`${prefix}Darch=${opt.arch}`);
|
|
args.push(`${prefix}Doutput=${opt.output}`);
|
|
args.push(`${prefix}NOCD`);
|
|
args.push(`${prefix}V2`);
|
|
args.push(opt.installScript);
|
|
const executable = win ? 'C:\\Program Files (x86)\\NSIS\\makensis.exe' : 'makensis';
|
|
grunt.log.writeln('Running NSIS:', args.join(' '));
|
|
grunt.util.spawn({
|
|
cmd: executable,
|
|
args: args,
|
|
opts: {stdio: 'inherit'}
|
|
}, (error, result, code) => {
|
|
if (error) {
|
|
return grunt.warn('NSIS error: ' + error);
|
|
}
|
|
if (code) {
|
|
return grunt.warn('NSIS exit code ' + code);
|
|
}
|
|
done();
|
|
});
|
|
});
|
|
};
|