From 80c94ff530a6480a56220c3ac14c0b311a74c02f Mon Sep 17 00:00:00 2001 From: Chris Gunawardena Date: Wed, 18 Nov 2015 12:33:02 +1100 Subject: [PATCH 1/4] Fix for warning 'Cannot delete files outside the current working directory', that halts the tests. --- tasks/phantomcss.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/phantomcss.js b/tasks/phantomcss.js index 2a05d74..94e798c 100644 --- a/tasks/phantomcss.js +++ b/tasks/phantomcss.js @@ -57,7 +57,7 @@ module.exports = function(grunt) { // Delete all of 'em diffScreenshots.forEach(function(filepath) { - grunt.file.delete(filepath); + grunt.file.delete(filepath, { force: true }); }); }; @@ -69,7 +69,7 @@ module.exports = function(grunt) { // Delete all of 'em diffScreenshots.forEach(function(filepath) { - grunt.file.delete(filepath); + grunt.file.delete(filepath, { force: true }); }); }; From e9247aa29a1083c5b93f3fb334d79f362a3fc5d6 Mon Sep 17 00:00:00 2001 From: Chris Gunawardena Date: Wed, 18 Nov 2015 12:37:28 +1100 Subject: [PATCH 2/4] Small readme file fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e006c19..d54cce3 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Or add the following line to your `package.json`: Then, once the plugin has been installed via `npm install`, it may be enabled inside your Gruntfile with this line of JavaScript: ```js -grunt.loadNpmTasks('grunt-phantomcss'); +grunt.loadNpmTasks('@micahgodbolt/grunt-phantomcss'); ``` ## The "phantomcss" task From 1f8c09ddc5e9470c4c92cae706719a621b6430ae Mon Sep 17 00:00:00 2001 From: Chris Gunawardena Date: Wed, 18 Nov 2015 17:07:51 +1100 Subject: [PATCH 3/4] Fixes so its cleaning up the .diff and .1.error files --- phantomjs/runner.js | 2 +- tasks/phantomcss.js | 48 +++++++++------------------------------------ 2 files changed, 10 insertions(+), 40 deletions(-) diff --git a/phantomjs/runner.js b/phantomjs/runner.js index d8db0ee..24468a5 100644 --- a/phantomjs/runner.js +++ b/phantomjs/runner.js @@ -70,7 +70,7 @@ phantomcss.init({ } else { return name + '.png'; } - }, + } }); casper.start(); diff --git a/tasks/phantomcss.js b/tasks/phantomcss.js index 94e798c..6de2889 100644 --- a/tasks/phantomcss.js +++ b/tasks/phantomcss.js @@ -48,27 +48,14 @@ module.exports = function(grunt) { // Create a temporary file for message passing between the task and PhantomJS var tempFile = new tmp.File(); - var deleteDiffScreenshots = function(folderpath) { + var deleteScreenshots = function(pattern) { // Find diff/fail files - var diffScreenshots = grunt.file.expand([ - path.join(folderpath + '/' + options.screenshots, '*diff.png'), - path.join(folderpath + '/' + options.screenshots, '*fail.png'), + var screenshots = grunt.file.expand([ + path.join(options.screenshots, pattern) ]); // Delete all of 'em - diffScreenshots.forEach(function(filepath) { - grunt.file.delete(filepath, { force: true }); - }); - }; - - var deleteDiffResults = function(folderpath) { - // Find diff/fail files - var diffScreenshots = grunt.file.expand([ - path.join(folderpath, options.results), - ]); - - // Delete all of 'em - diffScreenshots.forEach(function(filepath) { + screenshots.forEach(function(filepath) { grunt.file.delete(filepath, { force: true }); }); }; @@ -76,24 +63,7 @@ module.exports = function(grunt) { var cleanup = function(error) { // Remove temporary file tempFile.unlink(); - - options.testFolder.forEach(function(folderpath) { - // Create the output directory - grunt.file.mkdir(folderpath + '/' + options.results); - - // Copy fixtures, diffs, and failure images to the results directory - var allScreenshots = grunt.file.expand(path.join(folderpath + '/' + options.screenshots, '**.png')); - - allScreenshots.forEach(function(filepath) { - grunt.file.copy(filepath, path.join( - folderpath + '/' + options.results, - path.basename(filepath) - )); - }); - - deleteDiffScreenshots(folderpath); - }); - + deleteScreenshots('*diff.png'); done(error || failureCount === 0); }; @@ -180,8 +150,8 @@ module.exports = function(grunt) { // Remove old diff screenshots options.testFolder.forEach(function(folderpath) { - deleteDiffScreenshots(folderpath); - deleteDiffResults(folderpath); + deleteScreenshots('*diff.png'); + deleteScreenshots('*fail.png'); }); // Start watching for messages @@ -190,8 +160,8 @@ module.exports = function(grunt) { grunt.util.spawn({ cmd: phantomBinaryPath, args: [ - runnerPath, - JSON.stringify(options), + runnerPath, + JSON.stringify(options) ], opts: { cwd: cwd, From 2b8d102d484c9ada8c5e90d4fcd57d35ece65968 Mon Sep 17 00:00:00 2001 From: Chris Gunawardena Date: Wed, 18 Nov 2015 17:09:24 +1100 Subject: [PATCH 4/4] Added jscs Aribnb code format style preset --- .jscs.json | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .jscs.json diff --git a/.jscs.json b/.jscs.json new file mode 100644 index 0000000..b9eb182 --- /dev/null +++ b/.jscs.json @@ -0,0 +1,64 @@ +{ + "disallowSpacesInNamedFunctionExpression": { + "beforeOpeningRoundBrace": true + }, + "disallowSpacesInFunctionExpression": { + "beforeOpeningRoundBrace": true + }, + "disallowSpacesInAnonymousFunctionExpression": { + "beforeOpeningRoundBrace": true + }, + "disallowSpacesInFunctionDeclaration": { + "beforeOpeningRoundBrace": true + }, + "disallowEmptyBlocks": true, + "disallowSpacesInsideArrayBrackets": true, + "disallowSpacesInsideParentheses": true, + "disallowQuotedKeysInObjects": true, + "disallowSpaceAfterObjectKeys": true, + "disallowSpaceAfterPrefixUnaryOperators": true, + "disallowSpaceBeforePostfixUnaryOperators": true, + "disallowSpaceBeforeBinaryOperators": [ + "," + ], + "disallowMixedSpacesAndTabs": true, + "disallowTrailingWhitespace": true, + "disallowTrailingComma": true, + "disallowYodaConditions": true, + "disallowKeywords": [ "with" ], + "disallowMultipleLineBreaks": true, + "disallowMultipleVarDecl": true, + "requireSpaceBeforeBlockStatements": true, + "requireParenthesesAroundIIFE": true, + "requireSpacesInConditionalExpression": true, + "requireBlocksOnNewline": 1, + "requireCommaBeforeLineBreak": true, + "requireSpaceBeforeBinaryOperators": true, + "requireSpaceAfterBinaryOperators": true, + "requireCamelCaseOrUpperCaseIdentifiers": true, + "requireLineFeedAtFileEnd": true, + "requireCapitalizedConstructors": true, + "requireDotNotation": true, + "requireSpacesInForStatement": true, + "requireSpaceBetweenArguments": true, + "requireCurlyBraces": [ + "do" + ], + "requireSpaceAfterKeywords": [ + "if", + "else", + "for", + "while", + "do", + "switch", + "case", + "return", + "try", + "catch", + "typeof" + ], + "safeContextKeyword": "_this", + "validateLineBreaks": "LF", + "validateQuoteMarks": "'", + "validateIndentation": "\t" +} \ No newline at end of file