Skip to content

Commit 94deddf

Browse files
committed
Merge pull request #27 from bholloway/master
tweaks
2 parents 346ae50 + a3147be commit 94deddf

File tree

4 files changed

+57
-38
lines changed

4 files changed

+57
-38
lines changed

lib/build/node-sass.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,16 +232,29 @@ module.exports = function (bannerWidth, libraryPaths) {
232232
done();
233233
}
234234

235-
// perform the sass render
236-
sass.render({
237-
file : file.path,
238-
data : file.contents.toString(),
239-
success : successHandler,
240-
error : errorHandler,
241-
includePaths: libList,
242-
outputStyle : 'compressed',
243-
stats : { },
244-
sourceMap : mapName
235+
/**
236+
* Perform the sass render with the given <code>sourceMap</code>, <code>error</code>, and <code>success</code>
237+
* parameters.
238+
* @param {string|boolean} map The source map filename or <code>false</code> for none
239+
* @param {function ({string})} error Handler for error
240+
* @param {function ({string}, {string})} success Handler for success
241+
*/
242+
function render(map, error, success) {
243+
sass.render({
244+
file : file.path,
245+
data : file.contents.toString(),
246+
success : success,
247+
error : error,
248+
includePaths: libList,
249+
outputStyle : 'compressed',
250+
stats : { },
251+
sourceMap : map
252+
});
253+
}
254+
255+
// run first without source-map as this can cause process exit where errors exist
256+
render(false, errorHandler, function () {
257+
render(mapName, errorHandler, successHandler);
245258
});
246259

247260
}, function (done) {

lib/config/streams.js

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,42 @@
11
'use strict';
22

3-
var gulp = require('gulp'),
4-
path = require('path'),
5-
reduce = require('lodash.reduce'),
6-
slash = require('gulp-slash'),
7-
bowerDir = require('bower-directory');
3+
var gulp = require('gulp'),
4+
path = require('path'),
5+
flatten = require('lodash.flatten'),
6+
reduce = require('lodash.reduce'),
7+
slash = require('gulp-slash'),
8+
bowerDir = require('bower-directory');
89

910
var bowerFiles = require('../inject/bower-files');
1011

1112
var NODE = 'node_modules',
1213
BOWER = path.relative(process.cwd(), bowerDir.sync()),
1314
APP = 'app',
15+
GENERATED = 'app-*',
1416
BUILD = 'app-build',
1517
TEST = 'app-test',
1618
RELEASE_BUNDLE = 'app-release',
1719
RELEASE_VENDOR = 'app-release/vendor',
1820
ROUTES = reduce([ '', BOWER, BUILD ], mapRoutes, { });
1921

2022
/**
21-
* Create a glob with the given pattern elements, and additional directory
22-
* @param {Array|string} pattern One or more glob pattern entries to be included as-in
23-
* @param {Array|string} [additional] Any number of non-library directories to include
24-
* @return {Array} A multi-element glob pattern
23+
* Create a glob generator that features the given additional directories
24+
* @param {...string} [additional] Any number of non-library directories to include
25+
* @return {function({Array})} A multi-element glob pattern
2526
*/
26-
function getGlob(pattern, additional) {
27-
var patternArray = (typeof pattern === 'string') ? [ pattern ] : pattern || [];
28-
var additionalArray = (typeof additional === 'string') ? [ additional ] : additional || [];
29-
return patternArray.concat([NODE, BOWER, APP, BUILD, TEST, RELEASE_BUNDLE, RELEASE_VENDOR]
27+
function getGlob() {
28+
var additional = flatten(Array.prototype.slice.call(arguments));
29+
var excludes = [NODE, BOWER, APP, GENERATED]
3030
.filter(function convertAdditionalToExclude(element) {
31-
return (additionalArray.indexOf(element) < 0);
31+
return (additional.indexOf(element) < 0);
3232
})
33-
.map(function excludeDir(exclude) {
33+
.map(function excludeDirectory(exclude) {
3434
return '!' + exclude + '/**';
35-
}));
35+
});
36+
return function() {
37+
return flatten(Array.prototype.slice.call(arguments))
38+
.concat(excludes); // important - excludes must come after includes
39+
}
3640
}
3741

3842
function mapRoutes(result, path) {
@@ -45,11 +49,11 @@ function jsApp(opts) {
4549
}
4650

4751
function jsLib(opts) {
48-
return gulp.src(getGlob(['**/*.js', '!*.js', '!**/*.spec.js']), opts);
52+
return gulp.src(getGlob()('**/*.js', '!*.js', '!**/*.spec.js'), opts);
4953
}
5054

5155
function jsSpec(opts) {
52-
return gulp.src(getGlob(['**/*.spec.js', '!*.spec.js']), opts);
56+
return gulp.src(getGlob()('**/*.spec.js', '!*.spec.js'), opts);
5357
}
5458

5559
function scssApp(opts) {
@@ -63,7 +67,7 @@ function htmlApp(opts) {
6367
function testDependencies(opts) {
6468
return bowerFiles(80)
6569
.src('js', opts);
66-
};
70+
}
6771

6872
module.exports = {
6973
NODE : NODE,

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"scripts": {
1818
"test": "node ./node_modules/jasmine-node/bin/jasmine-node test"
1919
},
20-
"author": "Ben Holloway, Chris Decoster, Brendan Graetz",
20+
"contributors": ["bholloway", "impaler", "bguiz"],
2121
"license": "MIT",
2222
"repository": {
2323
"type": "git",
@@ -31,9 +31,10 @@
3131
"bin": {
3232
"angularity": "./bin/cli.js"
3333
},
34-
"engineStrict": true,
34+
"engineStrict": "true",
3535
"engines": {
36-
"node": ">= 0.9"
36+
"node": ">=0.10.28 <0.11",
37+
"npm": ">=2.0"
3738
},
3839
"dependencies": {
3940
"6to5ify": "latest",

tasks/watch.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,29 +65,30 @@ yargs.getInstance('watch')
6565
.wrap(80);
6666

6767
gulp.task('watch', ['server'], function () {
68+
var getGlobAppNodeBower = streams.getGlob(streams.APP, streams.NODE, streams.BOWER);
6869

6970
// enqueue actions to avoid multiple trigger
7071
var queue = watchSequence(500, function () {
7172
console.log(hr('\u2591', 80));
7273
});
7374

7475
// watch statements
75-
watch(streams.getGlob(['**/*.js', '**/*.html', '!*.*', '!**/*.spec.*'], [streams.APP, streams.NODE, streams.BOWER]), {
76+
watch(getGlobAppNodeBower('**/*.js', '**/*.html', '!' + streams.APP + '/**/*.html', '!*.*', '!**/*.spec.*'), {
7677
name : 'JS|HTML',
7778
emitOnGlob: false
78-
}, queue.getHandler('javascript', 'html', 'reload')); // app html will be needed in case previous injection failed
79+
}, queue.getHandler('javascript', 'html', 'reload')); // html will be needed in case previous injection failed
7980

80-
watch(streams.getGlob(['**/*.scss', '!*.scss'], [streams.APP, streams.NODE, streams.BOWER]), {
81+
watch(getGlobAppNodeBower(['**/*.scss', '!*.scss']), {
8182
name : 'CSS',
8283
emitOnGlob: false
8384
}, queue.getHandler('css', 'html', 'reload')); // html will be needed in case previous injection failed
8485

85-
watch([streams.BOWER + '/**/*', '!**/*.js', '!**/*.scss'], { // don't conflict with JS or CSS
86-
name : 'BOWER',
86+
watch([streams.APP + '/**/*.html', streams.BOWER + '/**/*', '!**/*.js', '!**/*.scss'], { // don't conflict JS or CSS
87+
name : 'INJECT',
8788
emitOnGlob: false
8889
}, queue.getHandler('html', 'reload'));
8990

90-
watch(streams.getGlob(['**/*.spec.js', '!*.spec.js']), {
91+
watch(streams.getGlob()(['**/*.spec.js', '!*.spec.js']), {
9192
name : 'TEST',
9293
emitOnGlob: false
9394
}, queue.getHandler('test'));

0 commit comments

Comments
 (0)