grunt-html-snapshots 1.0.2 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintignore ADDED
@@ -0,0 +1,2 @@
1
+ node_modules/
2
+ tmp/
package/.eslintrc.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "parserOptions": {
3
+ "ecmaVersion": 6,
4
+ "ecmaFeatures": {
5
+ "impliedStrict": true
6
+ }
7
+ },
8
+ "env": {
9
+ "node": true
10
+ },
11
+ "extends": [
12
+ "eslint:recommended"
13
+ ],
14
+ "rules": {
15
+ }
16
+ }
@@ -0,0 +1,29 @@
1
+ name: Verify
2
+ on:
3
+ push:
4
+ branches: [ master ]
5
+ pull_request:
6
+ branches: [ master ]
7
+
8
+ jobs:
9
+ verify:
10
+
11
+ runs-on: ubuntu-latest
12
+
13
+ strategy:
14
+ matrix:
15
+ node-version: [14.x, 16.x]
16
+ # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
17
+
18
+ steps:
19
+ - uses: actions/checkout@v3
20
+ - name: Use Node.js ${{ matrix.node-version }}
21
+ uses: actions/setup-node@v3.0.0
22
+ with:
23
+ node-version: ${{ matrix.node-version }}
24
+ - run: npm ci
25
+ - name: Lint
26
+ run: npm run lint
27
+ - name: Test
28
+ if: ${{ success() }}
29
+ run: npm test
package/Gruntfile.js CHANGED
@@ -2,27 +2,14 @@
2
2
  * grunt-html-snapshots
3
3
  * https://github.com/localnerve/grunt-html-snapshots
4
4
  *
5
- * Copyright (c) 2013, 2014 Alex Grant
5
+ * Copyright (c) 2013 - 2022 Alex Grant
6
6
  * Licensed under the MIT license.
7
7
  */
8
8
 
9
- 'use strict';
10
-
11
- module.exports = function(grunt) {
9
+ module.exports = function (grunt) {
12
10
 
13
11
  // Project configuration.
14
12
  grunt.initConfig({
15
- jshint: {
16
- all: [
17
- 'Gruntfile.js',
18
- 'tasks/*.js',
19
- '<%= nodeunit.tests %>',
20
- ],
21
- options: {
22
- jshintrc: '.jshintrc',
23
- },
24
- },
25
-
26
13
  // Before generating any new files, remove any previously-created files.
27
14
  clean: {
28
15
  tests: ['tmp'],
@@ -74,23 +61,22 @@ module.exports = function(grunt) {
74
61
  grunt.loadTasks('tasks');
75
62
 
76
63
  // These plugins provide necessary tasks.
77
- grunt.loadNpmTasks('grunt-contrib-jshint');
78
64
  grunt.loadNpmTasks('grunt-contrib-clean');
79
65
  grunt.loadNpmTasks('grunt-contrib-nodeunit');
80
66
 
81
67
  // Register the test server
82
68
  grunt.registerTask('test_server1', 'serve the test files', function(){
83
- var options = this.options();
84
- var server = require('./test/server');
69
+ const options = this.options();
70
+ const server = require('./test/server');
85
71
  server.start('./test/server', options.port);
86
72
  grunt.log.writeln("running test server on port "+options.port);
87
73
  grunt.log.ok();
88
74
  });
89
75
 
90
- grunt.registerTask('html_snapshots_options', 'prepare options for html_snapshots', function() {
91
- var optionsHelper = require("./test/helpers/options");
92
- var done = this.async();
93
- optionsHelper.detector(function(globalPhantom) {
76
+ grunt.registerTask('html_snapshots_options', 'prepare options for html_snapshots', function(){
77
+ const optionsHelper = require("./test/helpers/options");
78
+ const done = this.async();
79
+ optionsHelper.detector(globalPhantom => {
94
80
  if (globalPhantom) {
95
81
  var htmlSnapshots = grunt.config.get("html_snapshots");
96
82
  htmlSnapshots.options.phantomjs = "phantomjs";
@@ -106,6 +92,6 @@ module.exports = function(grunt) {
106
92
  grunt.registerTask('target2', ['clean', 'html_snapshots_options', 'html_snapshots:target2', 'nodeunit:target2']);
107
93
 
108
94
  // By default, lint and run all tests.
109
- grunt.registerTask('default', ['jshint', 'test']);
95
+ grunt.registerTask('default', ['test']);
110
96
 
111
97
  };
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Alex Grant
1
+ Copyright (c) 2013 - 2022 Alex Grant
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
package/README.md CHANGED
@@ -1,17 +1,14 @@
1
1
  # grunt-html-snapshots
2
2
 
3
- [![Greenkeeper badge](https://badges.greenkeeper.io/localnerve/grunt-html-snapshots.svg)](https://greenkeeper.io/)
4
-
5
3
  [![npm version](https://badge.fury.io/js/grunt-html-snapshots.svg)](http://badge.fury.io/js/grunt-html-snapshots)
6
- [![Build Status](https://secure.travis-ci.org/localnerve/grunt-html-snapshots.svg?branch=master)](http://travis-ci.org/localnerve/grunt-html-snapshots)
4
+ ![Verify](https://github.com/localnerve/grunt-html-snapshots/workflows/Verify/badge.svg)
7
5
  [![Dependency Status](https://david-dm.org/localnerve/grunt-html-snapshots.svg)](https://david-dm.org/localnerve/grunt-html-snapshots)
8
- [![devDependency Status](https://david-dm.org/localnerve/grunt-html-snapshots/dev-status.svg)](https://david-dm.org/localnerve/grunt-html-snapshots#info=devDependencies)
9
- [![devDependency Status](https://david-dm.org/localnerve/grunt-html-snapshots/peer-status.svg)](https://david-dm.org/localnerve/grunt-html-snapshots#info=peerDependencies)
10
6
 
11
7
  > The grunt task for [html-snapshots](http://github.com/localnerve/html-snapshots)
12
8
 
13
9
  ## Getting Started
14
- This plugin requires Grunt `>=0.4.0`
10
+ This plugin requires Grunt `>=1.0.0`
11
+ *To use an older Grunt, use this library at tag `#v1.0.2`*
15
12
 
16
13
  If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
17
14
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "grunt-html-snapshots",
3
3
  "description": "The grunt task for html-snapshots",
4
- "version": "1.0.2",
4
+ "version": "4.0.1",
5
5
  "homepage": "https://github.com/localnerve/grunt-html-snapshots",
6
6
  "author": {
7
7
  "name": "Alex Grant",
@@ -18,22 +18,23 @@
18
18
  "license": "MIT",
19
19
  "main": "Gruntfile.js",
20
20
  "engines": {
21
- "node": ">= 4.x"
21
+ "node": ">= 14"
22
22
  },
23
23
  "scripts": {
24
- "test": "grunt test"
24
+ "test": "grunt test",
25
+ "lint": "eslint ."
25
26
  },
26
27
  "dependencies": {
27
- "html-snapshots": ">= 0.14.0"
28
+ "html-snapshots": "^0.18.1"
28
29
  },
29
30
  "devDependencies": {
30
- "grunt-contrib-jshint": "^1.0.0",
31
- "grunt-contrib-clean": "^1.0.0",
32
- "grunt-contrib-nodeunit": "^2.0.0",
33
- "grunt": ">=0.4.5"
31
+ "eslint": "^8.12.0",
32
+ "grunt-contrib-clean": "^2.0.1",
33
+ "grunt-contrib-nodeunit": "^4.0.0",
34
+ "grunt": ">=1.0.0"
34
35
  },
35
36
  "peerDependencies": {
36
- "grunt": ">=0.4.5"
37
+ "grunt": ">=1.0.0"
37
38
  },
38
39
  "keywords": [
39
40
  "SEO",
@@ -2,45 +2,41 @@
2
2
  * grunt-html-snapshots
3
3
  * https://github.com/localnerve/grunt-html-snapshots
4
4
  *
5
- * Copyright (c) 2013 - 2017, LocalNerve, Alex Grant
5
+ * Copyright (c) 2013 - 2022, LocalNerve, Alex Grant
6
6
  * Licensed under the MIT license.
7
7
  */
8
- module.exports = function (grunt) {
9
-
10
- var html_snapshots = require('html-snapshots');
11
-
12
- grunt.registerMultiTask('html_snapshots', 'Generate html snapshots.',
13
- function () {
8
+ const html_snapshots = require('html-snapshots');
14
9
 
10
+ module.exports = function (grunt) {
11
+ grunt.registerMultiTask('html_snapshots', 'Generate html snapshots.', function () {
15
12
  // Merge task-specific and/or target-specific options with these defaults.
16
- var options = this.options({
13
+ const options = this.options({
17
14
  force: false
18
15
  });
19
16
 
20
17
  // Report html_snapshot errors but dont fail the task
21
- var force = options.force;
18
+ const force = options.force;
22
19
  delete options.force;
23
20
 
24
21
  grunt.verbose.writeflags(options, 'html_snapshots options');
25
22
 
26
23
  // Setup for async
27
- var done = this.async();
24
+ const done = this.async();
28
25
 
29
26
  // Take the snapshots
30
27
  html_snapshots.run(options)
31
- .then(function (completed) {
28
+ .then(() => {
32
29
  grunt.log.ok();
33
30
  })
34
- .catch(function (err) {
31
+ .catch(err => {
35
32
  grunt.log.error('html_snapshots failed');
36
33
  if (force) {
37
- grunt.log.error(''+err);
34
+ grunt.log.error(err);
38
35
  }
39
36
  return err;
40
37
  })
41
- .then(function (err) {
38
+ .then(err => {
42
39
  done(force ? undefined : err);
43
40
  });
44
41
  });
45
-
46
42
  };
@@ -8,22 +8,22 @@
8
8
  * In some test environments (travis), local phantomjs will not install if a global is found.
9
9
  */
10
10
 
11
- var spawn = require("child_process").spawn;
11
+ const spawn = require("child_process").spawn;
12
12
 
13
13
  module.exports = {
14
14
 
15
15
  // for now, callback is passed true if global phantomjs should be used
16
- detector: function(callback) {
16
+ detector: callback => {
17
17
  // try to run phantom globally
18
- var cp = spawn("phantomjs", ["--version"]);
18
+ const cp = spawn("phantomjs", ["--version"]);
19
19
 
20
20
  // if it fails, use local per the defaults
21
- cp.on("error", function(err) {
21
+ cp.on("error", () => {
22
22
  callback(false);
23
23
  });
24
24
 
25
25
  // if it succeeds, use the global
26
- cp.on("exit", function(code) {
26
+ cp.on("exit", code => {
27
27
  if (code === 0) {
28
28
  callback(true);
29
29
  }
@@ -1,41 +1,29 @@
1
- 'use strict';
2
-
3
- var grunt = require('grunt');
4
- var fs = require('fs');
5
-
6
- /*
7
- ======== A Handy Little Nodeunit Reference ========
8
- https://github.com/caolan/nodeunit
9
-
10
- Test methods:
11
- test.expect(numAssertions)
12
- test.done()
13
- Test assertions:
14
- test.ok(value, [message])
15
- test.equal(actual, expected, [message])
16
- test.notEqual(actual, expected, [message])
17
- test.deepEqual(actual, expected, [message])
18
- test.notDeepEqual(actual, expected, [message])
19
- test.strictEqual(actual, expected, [message])
20
- test.notStrictEqual(actual, expected, [message])
21
- test.throws(block, [error], [message])
22
- test.doesNotThrow(block, [error], [message])
23
- test.ifError(value)
24
- */
1
+ /**
2
+ * tests, target1
3
+ */
4
+ /* global Promise */
5
+ const grunt = require('grunt');
6
+ const { pathExists } = require('./utils');
25
7
 
26
8
  exports.html_snapshots = {
27
- setUp: function(done) {
9
+ setUp: done => {
28
10
  // setup here if necessary
29
11
  done();
30
12
  },
31
13
 
32
- target1: function(test) {
14
+ target1: test => {
33
15
  test.expect(3);
34
16
 
35
- grunt.file.read('test/expected/target1').split('\n').forEach(function(line){
36
- test.equal(true, fs.existsSync(line), line+" should exist");
17
+ const results = [];
18
+
19
+ grunt.file.read('test/expected/target1').split('\n').forEach(line => {
20
+ results.push(pathExists(line).then(exists => {
21
+ test.equal(true, exists, `${line} should exist`);
22
+ }));
37
23
  });
38
24
 
39
- test.done();
25
+ Promise.all(results).finally(()=> {
26
+ test.done();
27
+ })
40
28
  }
41
29
  };
@@ -1,41 +1,29 @@
1
- 'use strict';
2
-
3
- var grunt = require('grunt');
4
- var fs = require('fs');
5
-
6
- /*
7
- ======== A Handy Little Nodeunit Reference ========
8
- https://github.com/caolan/nodeunit
9
-
10
- Test methods:
11
- test.expect(numAssertions)
12
- test.done()
13
- Test assertions:
14
- test.ok(value, [message])
15
- test.equal(actual, expected, [message])
16
- test.notEqual(actual, expected, [message])
17
- test.deepEqual(actual, expected, [message])
18
- test.notDeepEqual(actual, expected, [message])
19
- test.strictEqual(actual, expected, [message])
20
- test.notStrictEqual(actual, expected, [message])
21
- test.throws(block, [error], [message])
22
- test.doesNotThrow(block, [error], [message])
23
- test.ifError(value)
24
- */
1
+ /**
2
+ * tests, target2
3
+ */
4
+ /* global Promise */
5
+ const grunt = require('grunt');
6
+ const { pathExists } = require('./utils');
25
7
 
26
8
  exports.html_snapshots = {
27
- setUp: function(done) {
9
+ setUp: done => {
28
10
  // setup here if necessary
29
11
  done();
30
12
  },
31
13
 
32
- target2: function(test) {
14
+ target2: test => {
33
15
  test.expect(3);
34
16
 
35
- grunt.file.read('test/expected/target2').split('\n').forEach(function(line){
36
- test.equal(false, fs.existsSync(line), line+" should not exist");
17
+ const results = [];
18
+
19
+ grunt.file.read('test/expected/target2').split('\n').forEach(line => {
20
+ results.push(pathExists(line).then(exists => {
21
+ test.equal(false, exists, `${line} should not exist`);
22
+ }));
37
23
  });
38
24
 
39
- test.done();
25
+ Promise.all(results).finally(() => {
26
+ test.done();
27
+ });
40
28
  }
41
29
  };
@@ -1,30 +1,13 @@
1
- 'use strict';
2
-
3
- var grunt = require('grunt');
4
- var fs = require('fs');
5
-
6
- /*
7
- ======== A Handy Little Nodeunit Reference ========
8
- https://github.com/caolan/nodeunit
9
-
10
- Test methods:
11
- test.expect(numAssertions)
12
- test.done()
13
- Test assertions:
14
- test.ok(value, [message])
15
- test.equal(actual, expected, [message])
16
- test.notEqual(actual, expected, [message])
17
- test.deepEqual(actual, expected, [message])
18
- test.notDeepEqual(actual, expected, [message])
19
- test.strictEqual(actual, expected, [message])
20
- test.notStrictEqual(actual, expected, [message])
21
- test.throws(block, [error], [message])
22
- test.doesNotThrow(block, [error], [message])
23
- test.ifError(value)
24
- */
1
+ /**
2
+ * Test the task
3
+ */
4
+ /* global Promise */
5
+
6
+ const grunt = require('grunt');
7
+ const { pathExists } = require('./utils');
25
8
 
26
9
  exports.html_snapshots = {
27
- setUp: function(done) {
10
+ setUp: function (done) {
28
11
  // setup here if necessary
29
12
  done();
30
13
  },
@@ -32,20 +15,32 @@ exports.html_snapshots = {
32
15
  target1: function(test) {
33
16
  test.expect(3);
34
17
 
35
- grunt.file.read('test/expected/target1').split('\n').forEach(function(line){
36
- test.equal(true, fs.existsSync(line), line+" should exist");
18
+ const results = [];
19
+
20
+ grunt.file.read('test/expected/target1').split('\n').forEach(line => {
21
+ results.push(pathExists(line).then(exists => {
22
+ test.equal(true, exists, `${line} should exist`);
23
+ }));
37
24
  });
38
25
 
39
- test.done();
26
+ Promise.all(results).finally(() => {
27
+ test.done();
28
+ });
40
29
  },
41
30
 
42
31
  target2: function(test) {
43
32
  test.expect(3);
44
33
 
45
- grunt.file.read('test/expected/target2').split('\n').forEach(function(line){
46
- test.equal(false, fs.existsSync(line), line+" should not exist");
34
+ const results = [];
35
+
36
+ grunt.file.read('test/expected/target2').split('\n').forEach(line => {
37
+ results.push(pathExists(line).then(exists => {
38
+ test.equal(false, exists, `${line} should not exist`);
39
+ }));
47
40
  });
48
41
 
49
- test.done();
42
+ Promise.all(results).finally(() => {
43
+ test.done();
44
+ });
50
45
  }
51
46
  };
package/test/utils.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * test utils
3
+ */
4
+ const fs = require('fs').promises;
5
+
6
+ function pathExists (path) {
7
+ return fs.access(path)
8
+ .then(() => true)
9
+ .catch(() => false);
10
+ }
11
+
12
+ module.exports = {
13
+ pathExists
14
+ };
package/.jshintrc DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "curly": true,
3
- "eqeqeq": true,
4
- "immed": true,
5
- "latedef": true,
6
- "newcap": true,
7
- "noarg": true,
8
- "sub": true,
9
- "undef": true,
10
- "boss": true,
11
- "eqnull": true,
12
- "node": true
13
- }
package/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- language: node_js
2
- node_js:
3
- - 4
4
- - 6
5
- before_script:
6
- - npm install -g grunt-cli