Mailspring/packages/client-app/build/tasks/create-mac-zip.js
Evan Morikawa a7686bb35b [client-app] build tasks now use absolute paths
Summary:
Grunt is hardcoded to use paths relative to wherever the Gruntfile is
located. Unfortunately it also expects the grunt packages to be siblings
of that gruntfile. We can get around this by changing the relative base
path, but then the cwd is different for each tasks. This is okay as long
as we use absolute paths for various files in each of our tasks. This
updates our grunt tasks to use absolute paths

Test Plan: `npm run build-client`

Reviewers: spang, halla, jerm, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3987
2017-02-21 14:35:51 -05:00

36 lines
892 B
JavaScript

/* eslint prefer-template: 0 */
/* eslint global-require: 0 */
/* eslint quote-props: 0 */
const path = require('path');
module.exports = (grunt) => {
const {spawn} = grunt.config('taskHelpers')
grunt.registerTask('create-mac-zip', 'Zip up Nylas Mail', function pack() {
const done = this.async();
const zipPath = path.join(grunt.config('outputDir'), 'NylasMail.zip');
if (grunt.file.exists(zipPath)) {
grunt.file.delete(zipPath, {force: true});
}
const orig = process.cwd();
process.chdir(path.join(grunt.config('outputDir'), 'Nylas Mail-darwin-x64'));
spawn({
cmd: "zip",
args: ["-9", "-y", "-r", "-9", "-X", zipPath, 'Nylas Mail.app'],
}, (error) => {
process.chdir(orig);
if (error) {
done(error);
return;
}
grunt.log.writeln(`>> Created ${zipPath}`);
done(null);
});
});
};