Skip to content

Commit

Permalink
Update code for post
Browse files Browse the repository at this point in the history
  • Loading branch information
jefflembeck committed Nov 15, 2014
1 parent 16d7b7d commit cbb5423
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 94 deletions.
47 changes: 10 additions & 37 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,32 @@
* Licensed under the MIT license.
*/

'use strict';

module.exports = function(grunt) {
'use strict';

// Project configuration.
grunt.initConfig({
jshint: {
all: [
'Gruntfile.js',
'tasks/*.js',
'<%= nodeunit.tests %>',
'lib/*.js'
],
options: {
jshintrc: '.jshintrc',
},
},

// Before generating any new files, remove any previously-created files.
clean: {
tests: ['tmp'],
jshintrc: '.jshintrc'
}
},

// Configuration to be run (and then tested).
screenshots: {
default_options: {
options: {
},
files: {
'tmp/default_options': ['test/fixtures/testing', 'test/fixtures/123'],
},
},
custom_options: {
options: {
separator: ': ',
punctuation: ' !!!',
},
files: {
'tmp/custom_options': ['test/fixtures/testing', 'test/fixtures/123'],
},
},
},

// Unit tests.
nodeunit: {
tests: ['test/*_test.js'],
},
url: 'http://alistapart.com/',
output: 'ala'
}
}
}

});

Expand All @@ -60,14 +40,7 @@ module.exports = function(grunt) {

// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-nodeunit');

// Whenever the "test" task is run, first clean the "tmp" dir, then run this
// plugin's task(s), then test the result.
grunt.registerTask('test', ['clean', 'screenshots', 'nodeunit']);

// By default, lint and run all tests.
grunt.registerTask('default', ['jshint', 'test']);
grunt.registerTask('default', ['jshint', 'screenshots']);

};
1 change: 1 addition & 0 deletions lib/screenshotter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ phantom args
(function(){
"use strict";

var system = require( "system" );
var page = require( "webpage" ).create();

var site = phantom.args[0],
Expand Down
11 changes: 11 additions & 0 deletions lib/shot-wrapper.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
/*global console:true*/
/*global require:true*/
/*global __dirname:true*/
(function(exports){
"use strict";

var path = require( "path" );

var execFile = require( "child_process" ).execFile;
var phantomPath = require( "phantomjs" ).path;
var phantomscript = path.resolve( path.join( __dirname, "screenshotter.js" ));

exports.takeShot = function( url, output, cb ){
if( !(typeof url === "string" && typeof output === "string") ){
throw new Error( "URL and output must be strings" );
}
if( !(url.length && output.length) ){
throw new Error( "URL and output must not be empty strings" );
}
execFile( phantomPath, [
phantomscript,
url,
output
],
Expand Down
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,11 @@
"engines": {
"node": ">= 0.8.0"
},
"scripts": {
"test": "grunt test"
},
"dependencies": {
"phantomjs": "1.9.11"
},
"devDependencies": {
"grunt-contrib-jshint": "~0.6.0",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-nodeunit": "~0.2.0",
"grunt": "~0.4.2"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion test/expected/custom_options

This file was deleted.

1 change: 0 additions & 1 deletion test/expected/default_options

This file was deleted.

1 change: 0 additions & 1 deletion test/fixtures/123

This file was deleted.

1 change: 0 additions & 1 deletion test/fixtures/testing

This file was deleted.

48 changes: 0 additions & 48 deletions test/screenshots_test.js

This file was deleted.

0 comments on commit cbb5423

Please sign in to comment.