Skip to content

Commit aebbf53

Browse files
Remove Grunt (#587)
* Delete Gruntfile.js * Remove all Grunt-related dependencies * Remove reference to Gruntfile from .npmignore * Rename undocumented `build:node` script to just `build` I intend to make it the build script in due course. Needs more steps currently. * Reimplement build command (I think? Need to compare output carefully) and stub test commands * Get tests running again, but without coverage * Bump to latest istanbul and get it working by roughly following https://istanbul.js.org/docs/tutorials/es2015/ * Restore mandatory 100% coverage * Replace a reference to grunt * Remove another grunt reference from the docs * Restore uglifyjs * Make yarn test always check coverage * oops * Restore support for in-browser testing * Remove unneeded stuff * Remove unnecessary noInfo option * Run yarn upgrade
1 parent 9e2da01 commit aebbf53

10 files changed

+2195
-2947
lines changed

.babelrc

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{
22
"sourceMaps": "inline",
33
"presets": ["@babel/preset-env"],
4-
"auxiliaryCommentBefore": "istanbul ignore start",
5-
"auxiliaryCommentAfter": "istanbul ignore end"
4+
"env": {
5+
"test": {
6+
"plugins": [
7+
"istanbul"
8+
]
9+
}
10+
}
611
}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ lib
55
dist
66
yarn-error.log
77
.vscode
8+
.nyc_output

.npmignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
.gitignore
44
.npmignore
55
.vscode
6+
.nyc_output
67
components
78
coverage
89
examples
9-
Gruntfile.js
1010
images
1111
index.html
1212
karma.conf.js

CONTRIBUTING.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,27 @@ Generally we like to see pull requests that
1212
- Have tests
1313
- Don't decrease the current code coverage (see coverage/lcov-report/index.html)
1414

15-
## Building
15+
## Building and testing
1616

1717
```
1818
yarn
1919
yarn test
2020
```
2121

22-
Running `yarn test -- dev` will watch for tests within Node and `karma start` may be used for manual testing in browsers.
22+
To run tests in a *browser* (for instance to test compatibility with Firefox, with Safari, or with old browser versions), run `yarn karma start`, then open http://localhost:9876/ in the browser you want to test in. Results of the test run will appear in the terminal where `yarn karma start` is running.
2323

2424
If you notice any problems, please report them to the GitHub issue tracker at
2525
[http://github.com/kpdecker/jsdiff/issues](http://github.com/kpdecker/jsdiff/issues).
2626

2727
## Releasing
2828

29+
Run a test in Firefox via the procedure above before releasing.
30+
2931
A full release may be completed by first updating the `"version"` property in package.json, then running the following:
3032

3133
```
3234
yarn clean
33-
yarn grunt release
35+
yarn build
3436
yarn publish
3537
```
3638

Gruntfile.js

-144
This file was deleted.

examples/web_example.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!-- If you want to try this example from within the jsdiff repo, run
2-
`yarn grunt` first to build ../dist/diff.js then open this HTML file in
2+
`yarn build` first to build ../dist/diff.js then open this HTML file in
33
a browser. -->
44
<pre id="display"></pre>
55
<script src="../dist/diff.js"></script>

karma.conf.js

-13
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
/* eslint-env node */
22
/* eslint-disable no-var, camelcase */
33
module.exports = function(config) {
4-
var customLaunchers = {
5-
HeadlessChrome: {
6-
base: 'ChromeHeadless',
7-
flags: ['--no-sandbox']
8-
}
9-
};
10-
114
config.set({
125
basePath: '',
136

@@ -32,19 +25,13 @@ module.exports = function(config) {
3225
]
3326
}
3427
},
35-
webpackMiddleware: {
36-
noInfo: true
37-
},
3828

3929
reporters: ['mocha'],
4030

41-
customLaunchers: customLaunchers,
4231
port: 9876,
4332
colors: true,
4433
logLevel: config.LOG_INFO,
4534
autoWatch: true,
4635
singleRun: false,
47-
48-
browsers: ['HeadlessChrome']
4936
});
5037
};

package.json

+31-19
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,15 @@
4242
"./*": "./*"
4343
},
4444
"scripts": {
45-
"clean": "rm -rf lib/ dist/",
46-
"build:node": "yarn babel --out-dir lib --source-maps=inline src",
47-
"test": "grunt"
45+
"clean": "rm -rf lib/ dist/ coverage/ .nyc_output/",
46+
"lint": "yarn eslint 'src/**/*.js' 'test/**/*.js'",
47+
"build": "yarn lint && yarn run-babel && yarn run-rollup && yarn run-uglify",
48+
"test": "nyc yarn _test",
49+
"_test": "yarn build && cross-env NODE_ENV=test yarn run-mocha",
50+
"run-babel": "babel --out-dir lib --source-maps=inline src",
51+
"run-rollup": "rollup -c rollup.config.mjs",
52+
"run-uglify": "uglifyjs dist/diff.js -c -o dist/diff.min.js",
53+
"run-mocha": "mocha --require ./runtime 'test/**/*.js'"
4854
},
4955
"devDependencies": {
5056
"@babel/cli": "^7.24.1",
@@ -55,33 +61,39 @@
5561
"@colors/colors": "^1.6.0",
5662
"babel-eslint": "^10.0.1",
5763
"babel-loader": "^9.1.3",
64+
"babel-plugin-istanbul": "^7.0.0",
5865
"chai": "^4.2.0",
66+
"cross-env": "^7.0.3",
5967
"eslint": "^5.12.0",
60-
"grunt": "^1.6.1",
61-
"grunt-babel": "^8.0.0",
62-
"grunt-cli": "^1.4.3",
63-
"grunt-contrib-clean": "^2.0.1",
64-
"grunt-contrib-copy": "^1.0.0",
65-
"grunt-contrib-uglify": "^5.2.2",
66-
"grunt-contrib-watch": "^1.1.0",
67-
"grunt-eslint": "^24.3.0",
68-
"grunt-exec": "^3.0.0",
69-
"grunt-karma": "^4.0.2",
70-
"grunt-mocha-istanbul": "^5.0.2",
71-
"grunt-mocha-test": "^0.13.3",
72-
"grunt-webpack": "^6.0.0",
73-
"istanbul": "github:kpdecker/istanbul",
7468
"karma": "^6.4.3",
75-
"karma-chrome-launcher": "^3.2.0",
7669
"karma-mocha": "^2.0.1",
7770
"karma-mocha-reporter": "^2.2.5",
7871
"karma-sourcemap-loader": "^0.4.0",
7972
"karma-webpack": "^5.0.1",
8073
"mocha": "^7.0.0",
74+
"nyc": "^17.1.0",
8175
"rollup": "^4.13.0",
8276
"rollup-plugin-babel": "^4.2.0",
77+
"uglify-js": "^3.19.3",
8378
"webpack": "^5.90.3",
8479
"webpack-dev-server": "^5.0.3"
8580
},
86-
"optionalDependencies": {}
81+
"optionalDependencies": {},
82+
"dependencies": {},
83+
"nyc": {
84+
"require": [
85+
"@babel/register"
86+
],
87+
"reporter": [
88+
"lcov",
89+
"text"
90+
],
91+
"sourceMap": false,
92+
"instrument": false,
93+
"check-coverage": true,
94+
"branches": 100,
95+
"lines": 100,
96+
"functions": 100,
97+
"statements": 100
98+
}
8799
}

test/mocha.opts

-2
This file was deleted.

0 commit comments

Comments
 (0)