Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
bf60c5b
Add linting to the npm test script.
impaler Mar 19, 2015
d306d06
jshint fixes cli.js.
impaler Mar 19, 2015
643164a
jshint fixes build.js.
impaler Mar 19, 2015
fe25ca8
jshint fixes css.js.
impaler Mar 19, 2015
cc1ac80
jshint fixes html.js.
impaler Mar 19, 2015
bb05a6d
jshint fixes init.js.
impaler Mar 19, 2015
a88d577
jshint fixes javascript.js.
impaler Mar 19, 2015
6919622
jshint fixes release.js.
impaler Mar 19, 2015
a620ee8
jshint fixes server.js.
impaler Mar 19, 2015
81767c7
jshint fixes test.js.
impaler Mar 19, 2015
e72a4eb
jshint fixes watch.js.
impaler Mar 19, 2015
e234c83
jshint fixe webstorm.js.
impaler Mar 19, 2015
9a62230
Adjust jshint configuration to allow javascript url syntax that confl…
impaler Mar 19, 2015
86f46b3
jshint fixes for specs.
impaler Mar 19, 2015
41c66f0
jshint fixes for browserify.js.
impaler Mar 19, 2015
80d3093
jshint fixes for node-sass.js.
impaler Mar 19, 2015
22b6b4b
jshint fixes for defaults.js.
impaler Mar 19, 2015
726701b
jshint fixes for platform.js.
impaler Mar 19, 2015
7d8bd06
jshint fixes for streams.js.
impaler Mar 19, 2015
1cae44a
jshint fixes for adjacent-files.js.
impaler Mar 19, 2015
caf812f
jshint fixes for brower-files.js.
impaler Mar 19, 2015
7826432
jshint fixes for karma.js.
impaler Mar 19, 2015
e0c0c3f
jshint fixes for hr.js.
impaler Mar 19, 2015
23275a1
jshint fixes for jshint-reporter.js.
impaler Mar 19, 2015
18bd5da
jshint fixes for task-yargs-run.js.
impaler Mar 19, 2015
31be93e
jshint fixes for task-yargs.js.
impaler Mar 19, 2015
baadcec
jshint fixes for yargs.js.
impaler Mar 19, 2015
4300cc1
Remove interactive menus, they maybe reimplemented in a future version.
impaler Mar 19, 2015
79847c6
=BG= fixing/ ignoring misc jshint violations
bguiz Mar 19, 2015
177bbb7
=BG= clean up extraneous yargs instance usages in individual tasks
bguiz Mar 19, 2015
63c451d
=BG= experimental commit to test if local jasmine installation works …
bguiz Mar 19, 2015
2802f26
=BG= update test directory fro jasmine-node
bguiz Mar 19, 2015
fe25d1e
=BG= try npm run test instead
bguiz Mar 19, 2015
e38025e
=BG= reinstate global install
bguiz Mar 19, 2015
5485ce9
removed dependency on global gulp
Mar 19, 2015
a66d309
Merge remote-tracking branch 'origin/jshint' into jshint
Mar 19, 2015
ddaac53
fail the build on lint error.
impaler Mar 19, 2015
5f6e194
fixed jshint warnings, most were valid only a couple are spurious
Mar 19, 2015
95c6c0b
Merge remote-tracking branch 'origin/jshint' into jshint
Mar 19, 2015
6b5ff57
run the linting test after the integration tests.
impaler Mar 19, 2015
ac39ece
Merge remote-tracking branch 'origin/jshint' into jshint
impaler Mar 19, 2015
50d8903
improvements suggested by @bguiz
Mar 20, 2015
e8725f6
Merge remote-tracking branch 'origin/jshint' into jshint
Mar 20, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"maxparams": 20,
"maxdepth": 5,
"maxlen": 120,
"scripturl": true,
"node": true,
"jasmine": true
}
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ matrix:
fast_finish: true
before_install:
- npm install -g npm@2.1.7
- npm i -g
- npm i -g jasmine-node
- npm install -g
- node -v
- npm -v
- jasmine-node --version
script:
- pwd && ls
- jasmine-node --verbose --test-dir /home/travis/build/angularity/node-angularity/test
- node node_modules/jasmine-node/bin/jasmine-node --version
- npm run test
8 changes: 3 additions & 5 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ var path = require('path'),
gulp = require('gulp'),
gutil = require('gulp-util'),
wordwrap = require('wordwrap'),
runSequence = require('run-sequence'),
chalk = require('chalk'),
prettyTime = require('pretty-hrtime'),
yargs = require('yargs');

var taskYargs = require('../lib/util/task-yargs'),
taskYargsRun = require('../lib/util/task-yargs-run');
var taskYargsRun = require('../lib/util/task-yargs-run');

// TODO @bholloway menus
// var mainMenu = require('../lib/cli/mainMenu');
Expand Down Expand Up @@ -51,8 +49,8 @@ var defaultYargsInstance = yargs
].join('\n')))
// .example('angularity', 'Interactive menu') //TODO reinstate when interactive menu is reinstated
.example('angularity -v', 'Display the version of angularity')
.example('angularity \<task name\> -h', 'Get help on a particular task')
.example('angularity \<task name\>', 'Run the given task')
.example('angularity <task name> -h', 'Get help on a particular task')
.example('angularity <task name>', 'Run the given task')
.option('version', {
describe: 'Display the curent version',
alias: ['v'],
Expand Down
123 changes: 71 additions & 52 deletions lib/build/browserify.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
'use strict';

var fs = require('fs'),
path = require('path'),
through = require('through2'),
path = require('path');

var through = require('through2'),
merge = require('lodash.merge'),
trackFilenames = require('gulp-track-filenames'),
transformTools = require('browserify-transform-tools'),
Expand All @@ -22,7 +23,7 @@ var fs = require('fs'),
function isLiteralAST(node) {
var candidates = Array.prototype.slice.call(arguments, 1);
return (node) && (node.type === 'Literal') && candidates.some(function (candidate) {
return (node.value === candidate)
return (node.value === candidate);
});
}

Expand All @@ -49,7 +50,7 @@ function isMethodAST(node) {
* @return A jasmine transform
*/
function jasmineTransform(symbol) {
return transformTools.makeFalafelTransform('jasmineTransform', null, function (node, options, done) {
return transformTools.makeFalafelTransform('jasmineTransform', null, function jasmineASTWalker(node, options, done) {
var isValid = isLiteralAST(node, symbol) && isMethodAST(node.parent, 'describe', 'module');
if (isValid) {
node.update('\'' + options.file.replace(/\\/g, '\\\\') + ':0:0\'');
Expand Down Expand Up @@ -112,11 +113,11 @@ function compile(bannerWidth, transforms) {
* @return {string} The transformed file path
*/
function rootRelative(filePath, i, array) {
var rootRelative = slash(path.relative(process.cwd(), path.resolve(filePath))); // resolve relative references
var isProject = (rootRelative.slice(0, 2) !== '..');
var result = [
var rootRelPath = slash(path.relative(process.cwd(), path.resolve(filePath))); // resolve relative references
var isProject = (rootRelPath.slice(0, 2) !== '..');
var result = [
sourceMapBase || '',
isProject ? rootRelative : path.basename(rootRelative)
isProject ? rootRelPath : path.basename(rootRelPath)
].join(path.sep);
if ((typeof i === 'number') && (typeof array === 'object')) {
array[i] = result;
Expand All @@ -130,7 +131,7 @@ function compile(bannerWidth, transforms) {
var BOWER = path.relative(process.cwd(), bowerDir.sync());
return transformTools.makeRequireTransform('requireTransform', null, function (args, opts, done) {

// transform the original path where relevent
// transform the original path where relevant
var original = args[0];
var split = original.split(/[\\\/]/g); // keep delimiters
var firstTerm = split.splice(0, 1)[0]; // remove the first term from the split
Expand Down Expand Up @@ -178,39 +179,57 @@ function compile(bannerWidth, transforms) {
// error handler
var timeout;
function errorHandler(error) {
var text = error.toString();
var analysis;
var message;

// SyntaxError: <file>:<reason>:<line>:<column>
if (analysis = /^\s*SyntaxError\:\s*([^:]*)\s*\:\s*([^(]*)\s*\((\d+:\d+)\)\s*\n/.exec(text)) {
message = [analysis[1], analysis[3], analysis[2]].join(':') + '\n';

// Error: SyntaxError: <reason> while parsing json file <file>
} else if (analysis = /^\s*Error: SyntaxError\:\s*(.*)\s*while parsing json file\s*([^]*)/.exec(text)) {
message = [analysis[2], '0', '0', ' ' + analysis[1]].join(':') + '\n';

// Line <line>: <reason>: <file>
} else if (analysis = /Line\s*(\d+)\s*\:\s*([^:]*)\s*:\s*(.*)\s*/.exec(text)) {
message = [analysis[3], analysis[1], 0, ' ' + analysis[2]].join(':') + '\n';

// Error: Cannot find module '<reason>' from '<directory>'
// find the first text match for any text quoted in <reason>
} else if (analysis = /^\s*Error\: Cannot find module '(.*)\'\s*from\s*\'(.*)\'\s*$/.exec(text)) {
var filename = fs.readdirSync(analysis[2])
.filter(RegExp.prototype.test.bind(/\.js$/i))
.filter(function (jsFilename) {
var fullPath = path.join(analysis[2], jsFilename);
var fileText = fs.readFileSync(fullPath).toString();
return (new RegExp('[\'"]' + analysis[1] + '[\'"]')).test(fileText);
})
.shift();
message = path.join(analysis[2], filename) + ':0:0: Cannot find import ' + analysis[1] + '\n';

// Unknown
} else {
message = 'TODO parse this error\n' + text + '\n';
}

// run a bunch of tests against the error in order to determine the appropriate error message
// there will be at least one truthy value, even if that is the final placeholder
var text = error.toString();
var message = [

// SyntaxError: <file>:<reason>:<line>:<column>
function testSyntaxError() {
var analysis = /^\s*SyntaxError\:\s*([^:]*)\s*\:\s*([^(]*)\s*\((\d+:\d+)\)\s*\n/.exec(text);
return analysis && ([analysis[1], analysis[3], analysis[2]].join(':') + '\n');
},

// Error: SyntaxError: <reason> while parsing json file <file>
function testSyntaxErrorJSON() {
var analysis = /^\s*Error: SyntaxError\:\s*(.*)\s*while parsing json file\s*([^]*)/.exec(text);
return analysis && ([analysis[2], '0', '0', ' ' + analysis[1]].join(':') + '\n');
},

// Line <line>: <reason>: <file>
function testGeneric() {
var analysis = /Line\s*(\d+)\s*\:\s*([^:]*)\s*:\s*(.*)\s*/.exec(text);
return analysis && ([analysis[3], analysis[1], 0, ' ' + analysis[2]].join(':') + '\n');
},

// Error: Cannot find module '<reason>' from '<directory>'
// find the first text match for any text quoted in <reason>
function testBadImport() {
var analysis = /^\s*Error\: Cannot find module '(.*)\'\s*from\s*\'(.*)\'\s*$/.exec(text);
if (analysis) {
var filename = fs.readdirSync(analysis[2])
.filter(RegExp.prototype.test.bind(/\.js$/i))
.filter(function (jsFilename) {
var fullPath = path.join(analysis[2], jsFilename);
var fileText = fs.readFileSync(fullPath).toString();
return (new RegExp('[\'"]' + analysis[1] + '[\'"]')).test(fileText);
})
.shift();
return path.join(analysis[2], filename) + ':0:0: Cannot find import ' + analysis[1] + '\n';
}
},

// Unknown
function otherwise() {
return 'TODO parse this error\n' + text + '\n';
}
]
.map(function invokeTestMethod(testMethod) {
return testMethod();
})
.filter(Boolean)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not as intended. We want the final method above to be the fall-through. As it stands, it will be added always.

.shift();

// add unique
if (output.indexOf(message) < 0) {
Expand Down Expand Up @@ -238,7 +257,7 @@ function compile(bannerWidth, transforms) {
// transforms
transforms
.concat(requireTransform(false))
.forEach(function (item, i, list) {
.forEach(function eachItem(item, i, list) {
if (typeof item === 'function') {
var opts = (typeof list[i+1] === 'object') ? merge({ global: true }, list[i+1]) : { global: true };
bundler.transform(item, opts);
Expand All @@ -247,7 +266,7 @@ function compile(bannerWidth, transforms) {

// require statements
[].concat(files)
.forEach(function (item) {
.forEach(function eachItem(item) {
bundler.require(item, {entry: true});
});

Expand All @@ -258,7 +277,7 @@ function compile(bannerWidth, transforms) {
uglify : {
compress: { // anything that changes semicolons to commas will cause debugger problems
sequences: false,
join_vars: false
join_vars: false // jshint ignore:line
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'join_vars': false

possible?

},
mangle : {
toplevel: true
Expand All @@ -269,7 +288,7 @@ function compile(bannerWidth, transforms) {

// when we use minification we will get: error, code, source-map
// when we don't we will get: error, buffer(with embedded source map)
bundler.bundle(function (error, codeOrBuffer, map) {
bundler.bundle(function onComplete(error, codeOrBuffer, map) {
if (!error) {
var code = codeOrBuffer.toString();
var sourceMap = map ? JSON.parse(map) : convert.fromComment(code).toObject();
Expand All @@ -296,10 +315,10 @@ function compile(bannerWidth, transforms) {
* @param {string} [sourceMapBase] Base path for source map file
* @returns {stream.Through}
*/
each: function (isMinify, sourceMapBase) {
return through.obj(function (file, encoding, done) {
each: function gulpBundleEach(isMinify, sourceMapBase) {
return through.obj(function transformFn(file, encoding, done) {
bundle(this, [file.path], file.relative, isMinify, sourceMapBase, done);
}, function (done) {
}, function flushFn(done) {
flushErrors();
done();
});
Expand All @@ -312,12 +331,12 @@ function compile(bannerWidth, transforms) {
* @param {string} [sourceMapBase] Base path for source map file
* @returns {stream.Through}
*/
all: function (outPath, isMinify, sourceMapBase) {
all: function gulpBundleAll(outPath, isMinify, sourceMapBase) {
var pending = [];
return through.obj(function (file, encoding, done) {
return through.obj(function transformFn(file, encoding, done) {
pending.push(file.path);
done();
}, function (done) {
}, function flushFn(done) {
if (pending.length) {
bundle(this, pending, outPath, isMinify, sourceMapBase, function () {
flushErrors();
Expand Down
54 changes: 32 additions & 22 deletions lib/build/node-sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,32 @@ function encodeRelativeURL(startPath, uri) {
*/
function notPackage(absolutePath) {
return ['package.json', 'bower.json'].every(function fileNotFound(file) {
return !(fs.existsSync(path.resolve(absolutePath, file)));
return !(fs.existsSync(path.resolve(absolutePath, file)));
});
}

/**
* Enqueue subdirectories that are not packages and are not in the root path
* @param {Array} queue The queue to add to
* @param {string} basePath The path to consider
*/
function enqueue(queue, basePath) {
fs.readdirSync(basePath)
.filter(function notHidden(filename) {
return (filename.charAt(0) !== '.');
})
.map(function toAbsolute(filename) {
return path.join(basePath, filename);
})
.filter(function directoriesOnly(absolutePath) {
return fs.statSync(absolutePath).isDirectory();
})
.filter(function notInRootPath(absolutePath) {
return (pathToRoot.indexOf(absolutePath) < 0);
})
.filter(notPackage)
.forEach(function enqueue(absolutePath) {
queue.push(absolutePath);
});
}

Expand All @@ -37,10 +62,11 @@ function encodeRelativeURL(startPath, uri) {
if (absoluteStart) {

// find path to the root, stopping at cwd, package.json or bower.json
var pathToRoot = [ ];
var pathToRoot = [];
var isWorking;
do {
pathToRoot.push(absoluteStart);
var isWorking = (absoluteStart !== process.cwd()) && notPackage(absoluteStart);
isWorking = (absoluteStart !== process.cwd()) && notPackage(absoluteStart);
absoluteStart = path.resolve(absoluteStart, '..');
} while (isWorking);

Expand All @@ -64,23 +90,7 @@ function encodeRelativeURL(startPath, uri) {
}
// enqueue subdirectories that are not packages and are not in the root path
else {
fs.readdirSync(basePath)
.filter(function notHidden(filename) {
return (filename.charAt(0) !== '.');
})
.map(function toAbsolute(filename) {
return path.join(basePath, filename);
})
.filter(function directoriesOnly(absolutePath) {
return fs.statSync(absolutePath).isDirectory();
})
.filter(function notInRootPath(absolutePath) {
return (pathToRoot.indexOf(absolutePath) < 0);
})
.filter(notPackage)
.forEach(function enqueue(absolutePath) {
queue.push(absolutePath);
});
enqueue(queue, basePath);
}
}
}
Expand Down Expand Up @@ -109,7 +119,7 @@ module.exports = function (bannerWidth, libraryPaths) {

/**
* Push file contents to the output stream.
* @param {string} ext The extention for the file, including dot
* @param {string} ext The extension for the file, including dot
* @param {string|object?} contents The contents for the file or fields to assign to it
* @return {vinyl.File} The file that has been pushed to the stream
*/
Expand All @@ -136,7 +146,7 @@ module.exports = function (bannerWidth, libraryPaths) {
function reworkPlugin(stylesheet) {

// visit each node (selector) in the stylesheet recursively using the official utility method
visit(stylesheet, function (declarations, node) {
visit(stylesheet, function (declarations) {

// each node may have multiple declarations
declarations.forEach(function (declaration) {
Expand Down
Loading