-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
114 lines (98 loc) · 2.81 KB
/
gulpfile.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
'use strict';
var async = require('async');
var gulp = require('gulp');
var install = require("gulp-install");
var nodemon = require("gulp-nodemon");
var jshint = require('gulp-jshint');
var sass = require('gulp-ruby-sass');
var fse = require("fs-extra");
var exec = require('child_process').exec;
var wiredep = require('wiredep').stream;
var rename = require('gulp-rename');
var nwb = require('nw-builder');
var gutil = require('gulp-util');
var browserify = require('gulp-browserify');
var debowerify = require("debowerify");
var find = require('all-requires');
var gcallback = require('gulp-callback');
gulp.task('install', function() {
gulp.src(['./bower.json']).pipe(install());
if(!fse.existsSync('./app/partials')) fse.mkdirSync('./app/partials');
});
gulp.task('bower', function () {
gulp.src('app/layouts/index.hbs')
.pipe(wiredep({
ignorePath: '..'
}))
.pipe(gulp.dest('app/layouts'));
});
gulp.task('sass', function() {
sass('app/static/style/style.scss', {
style : "compact",
compass : true,
trace: false
})
.pipe(gulp.dest('app/static/style'));
});
gulp.task('lint', function () {
gulp.src('./app/**/*.js')
.pipe(jshint())
});
gulp.task('desktop', ['sass', 'lint'], function () {
var theReturn = undefined;
async.series([
function(callback) {
fse.removeSync('./app/gui/node_modules/');
fse.ensureDirSync('./app/gui/node_modules/');
callback();
},
function(callback) {
find({ path: './app/lib', onlyLocal: false }, function (err, requires) {
requires.forEach(function(module) {
fse.copySync('./node_modules/' + module, './app/gui/node_modules/' + module);
});
callback();
});
},
function(callback) {
fse.copySync('./app/lib/', './app/gui/lib/');
gulp.src('./app/static/script/index.js')
.pipe(browserify({
transform: ['debowerify']
}))
.pipe(rename('static.js'))
.pipe(gulp.dest('./app/gui'))
.pipe(gcallback(function() {
callback();
}));
},
], function(err, results) {
var nw = new nwb({
version: '0.12.2',
files: './app/gui/**',
macPlist: { mac_bundle_id: 'myPkg' },
platforms: ['win32', 'win64', 'osx32', 'osx64']
});
nw.on('log', function (msg) {
gutil.log('node-webkit-builder', msg);
});
return nw.build().catch(function (err) {
gutil.log('node-webkit-builder', err);
});
});
});
gulp.task('mobile', ['sass', 'lint'], function () {
});
gulp.task('server', ['sass', 'lint'], function() {
nodemon({
script: 'app/server.js',
ext: 'html js hbs scss json',
ignore: ['ignored.js'],
nodeArgs: ['--harmony']
})
.on('change', ['sass', 'lint'])
.on('restart', function () {
console.log('restarted!')
})
});
gulp.task('default', ['server']);