Skip to content
This repository was archived by the owner on Jul 15, 2021. It is now read-only.

Commit 4e58f8b

Browse files
committed
Get build tasks working in Windows.
1 parent 7afeb3c commit 4e58f8b

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

Gruntfile.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
var path = require('path');
2+
var fs = require('fs');
3+
14
module.exports = function(grunt) {
25
function getBanner(isDemo) {
36
return '/*!\n' +
@@ -6,7 +9,20 @@ module.exports = function(grunt) {
69
' * @author Nick Wronski <nick@javascript.com>\n' +
710
' */';
811
}
9-
const mochaCmd = './node_modules/.bin/mocha --compilers js:babel-core/register';
12+
function getCmdString(cmd, args) {
13+
if (!args) args = '';
14+
const binPath = path.normalize(`node_modules/.bin/${cmd}`);
15+
return `${binPath} ${customArgs[cmd]} ${args}`.trim();
16+
}
17+
const customArgs = {
18+
mocha: '--compilers js:babel-core/register',
19+
pegjs: `--trace --cache --optimize size -e parser src/grammar.pegjs .tmp/parser.js`
20+
};
21+
22+
const tmpDir = './.tmp/';
23+
if (!fs.existsSync(tmpDir)){
24+
fs.mkdirSync(tmpDir);
25+
}
1026
grunt.initConfig({
1127
pkg: grunt.file.readJSON('package.json'),
1228
browserify: {
@@ -106,27 +122,27 @@ module.exports = function(grunt) {
106122
options: {
107123
failOnError: true
108124
},
109-
command: './node_modules/.bin/pegjs --trace --cache --optimize size -e parser src/grammar.pegjs .tmp/parser.js'
125+
command: getCmdString('pegjs')
110126
},
111127
test: {
112128
options: {
113129
failOnError: true
114130
},
115-
command: `${mochaCmd} --reporter=nyan`
131+
command: getCmdString('mocha', '--reporter=nyan')
116132
},
117133
debug: {
118134
options: {
119135
failOnError: false,
120136
debounceDelay: 500,
121137
forever: true
122138
},
123-
command: `DEBUG=true ${mochaCmd}`
139+
command: `DEBUG=true ${getCmdString('mocha')}`
124140
},
125141
rewrite: {
126142
options: {
127143
failOnError: true
128144
},
129-
command: `REWRITE=true ${mochaCmd}`
145+
command: `REWRITE=true ${getCmdString('mocha')}`
130146
}
131147
},
132148
connect: {

0 commit comments

Comments
 (0)