forked from phonegap/phonegap-app-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
86 lines (73 loc) · 2.89 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
less: {
development: {
files: {
'www/css/index.css': 'src/less/index.less'
}
}
},
nodewebkit: {
options: {
version: '0.10.5',
build_dir: './build', // Destination for built apps.
mac: true, // OS X support.
win: true, // Windows support.
linux32: true, // Linux 32-bit support.
linux64: true, // Linux 64-bit support.
credits: 'www/credits.html',
mac_icns: 'www/img/app-icons/icon.icns',
winIco: 'www/img/app-icons/icon.ico'
},
src: ['./www/**/*', './node_modules/phonegap/**/*']
},
watch: {
files: ['./src/less/**/*'],
tasks: ['less']
}
});
// Load the grunt plugins.
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-node-webkit-builder');
// Register the task to install nodewebkit dependencies.
grunt.task.registerTask('install-dependencies', function() {
var exec = require('child_process').exec,
callback = this.async();
exec('npm install --production', { cwd: './www' }, function(e, stdout, stderr) {
console.log(stdout);
callback();
});
});
grunt.task.registerTask('copy-dev-config', function() {
//var config = grunt.file.read('./src/config/package.json');
grunt.file.copy('./src/config/package.json', './www/package.json');
});
grunt.task.registerTask('copy-release-config', function() {
var config = grunt.file.read('./src/config/package.json');
var releaseConfig = config.replace("\"toolbar\": true", "\"toolbar\": false");
grunt.file.write('./www/package.json', releaseConfig);
});
grunt.task.registerTask('copy-eula', function() {
grunt.file.copy('./src/license.txt', './res/installers/osx/license.txt');
grunt.file.copy('./src/license.txt', './res/installers/win/license.txt');
});
// Register the task to open an app.
grunt.task.registerTask('open', 'Open the app', function() {
var fs = require('fs'),
os = require('os'),
opener = require('opener'),
appName = JSON.parse(fs.readFileSync('./www/package.json')).name,
macPath = 'build/appName/osx/appName.app',
winPath = 'build/appName/win/appName.exe';
macPath = macPath.replace(/appName/g, appName);
winPath = winPath.replace(/appName/g, appName);
opener((os.platform() === 'darwin') ? macPath : winPath);
});
// Default tasks.
grunt.registerTask('default', ['install-dependencies', 'less', 'copy-dev-config', 'copy-eula', 'nodewebkit', 'open']);
grunt.registerTask('release', ['install-dependencies', 'less', 'copy-release-config', 'copy-eula', 'nodewebkit']);
};