pitaya-launcher/Gruntfile.js

119 lines
2.4 KiB
JavaScript

/* jshint node: true */
var _ = require('lodash');
var path = require('path');
module.exports = function(grunt) {
var NW_VERSION = '0.12.2';
var BUILD_DIR = 'build';
var BUILD_TARGETS = {
linux_ia32: true,
linux_x64: true,
win: false,
osx: false
};
var PKG = grunt.file.readJSON('package.json');
var PKG_OVERWRITE = {
window: {
toolbar: false,
kiosk: true
}
};
// Create build tasks options
var buildOptions = _.merge({
runtimeVersion: NW_VERSION
}, BUILD_TARGETS);
// Define copy:build tasks files
var appFiles = [];
_.forEach(BUILD_TARGETS, function(isEnabled, target) {
if(!isEnabled) return;
var arch = 'ia32';
var platform = target;
if(platform.indexOf('linux') !== -1) {
arch = platform.split('_')[1];
platform = 'linux';
}
var dirName = PKG.name + '-' + PKG.version + '-' + platform + '-' + arch;
var destPath = path.join(BUILD_DIR, dirName + '/');
// Retreive NPM dependencies
var npmDeps = _.keys(PKG.dependencies).map(function(moduleName) {
return path.join('node_modules', moduleName, '**');
});
appFiles.push({ src: npmDeps, dest: destPath });
// Add main files, licence, & config
appFiles.push({
src: [
'index.html',
'package.json',
'default-profile.json',
'LICENCE',
'css/**',
'js/**',
'img/**'
],
dest: destPath
});
});
// Configure tasks
grunt.initConfig({
pkg: PKG,
download: {
options: {
runtimeVersion: NW_VERSION
}
},
run: {
options: {
nwArgs: ['.'].concat(process.argv.slice(3)),
runtimeVersion: NW_VERSION
}
},
build: {
options: buildOptions
},
clean: {
build: [BUILD_DIR]
},
copy: {
build: {
files: appFiles,
options: {
noProcess: ['**','!package.json'],
process: function() {
var pkg = _.merge(PKG, PKG_OVERWRITE);
return JSON.stringify(pkg, null, 2);
}
}
}
}
});
grunt.registerTask('pitaya:run', ['download', 'run']);
grunt.registerTask(
'pitaya:build',
['download', 'build', 'copy:build']
);
grunt.registerTask('default', ['pitaya:run']);
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-nw');
};