Skip to content

Commit d80a986

Browse files
authored
Build: Use qunit/ during development instead of dist/
Use the same directory structure for the build artefact during releases and during development. Since the release file path is used by published npm and bower packages, keep that as-is, and rename the internal development target from dist/ to qunit/. After this, contributors and maintainers will want to delete any dist/ directory they might have, to avoid accidental linting or publishing.
1 parent 3539ce1 commit d80a986

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+125
-131
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
"__codeorigin/**",
3737
"coverage/**",
3838
"docs/_site/**",
39-
"dist/**",
4039
"lib/**",
40+
"qunit/**",
4141
"temp/**"
4242
],
4343
"overrides": [

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/.nyc_output
22
/__codeorigin
33
/coverage
4-
/dist
54
/node_modules
6-
/browserstack-run.pid
5+
/qunit
76
/temp
87
/docs/_site/

Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module.exports = function( grunt ) {
4646

4747
"src-css": {
4848
src: "src/qunit.css",
49-
dest: "dist/qunit.css"
49+
dest: "qunit/qunit.css"
5050
}
5151
},
5252
eslint: {

RELEASE.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ This guide walks you through the QUnit release.
8989
npm run build
9090
```
9191
92-
* Rename `dist/` to `qunit/`:
93-
```
94-
mv dist/ qunit/
95-
```
96-
9792
* Review the changes to the package and library files, compared to the previous release.
9893
```
9994
node build/review-package.js @LAST_VERSION

build/tasks/test-on-node.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = function( grunt ) {
1818
}
1919

2020
// Refresh the QUnit global to be used in other tests
21-
global.QUnit = requireFresh( "../../dist/qunit" );
21+
global.QUnit = requireFresh( "../../qunit/qunit.js" );
2222

2323
done( !totals.failed );
2424
} );
@@ -33,7 +33,7 @@ module.exports = function( grunt ) {
3333

3434
// Resolve current QUnit path and remove it from the require cache
3535
// to avoid stacking the QUnit logs.
36-
var QUnit = requireFresh( "../../dist/qunit" );
36+
var QUnit = requireFresh( "../../qunit/qunit.js" );
3737

3838
// Expose QUnit to the global scope to be seen on the other tests.
3939
global.QUnit = QUnit;

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@
9191
"authors": "grunt authors",
9292
"coverage": "npm run build:coverage && npm run coverage:_cli && npm run coverage:_main && nyc report",
9393
"coverage:_cli": "nyc --use-spawn-wrap --silent bin/qunit.js test/cli/*.js",
94-
"coverage:_main": "nyc instrument --in-place dist/ && grunt connect:nolivereload qunit",
94+
"coverage:_main": "nyc instrument --in-place qunit/ && grunt connect:nolivereload qunit",
9595
"coveralls": "npm run coverage && cat coverage/lcov.info | coveralls"
9696
},
9797
"nyc": {
9898
"include": [
9999
"bin/**",
100-
"dist/**",
100+
"qunit/**",
101101
"src/**"
102102
],
103103
"reporter": [

rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const isCoverage = process.env.BUILD_TARGET === "coverage";
1212
module.exports = {
1313
input: "src/qunit.js",
1414
output: {
15-
file: "dist/qunit.js",
15+
file: "qunit/qunit.js",
1616
sourcemap: isCoverage,
1717
format: "iife",
1818
exports: "none",

src/cli/require-qunit.js

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,19 @@
33
module.exports = function requireQUnit( resolve = require.resolve ) {
44
try {
55

6-
// First we attempt to find QUnit relative to the current working directory.
6+
// For:
7+
//
8+
// - QUnit is installed as local dependency and invoked normally
9+
// within the current project, e.g. via `npm test`, `npm run …`,
10+
// or `node_modules/.bin/qunit`.
11+
// The below will lead to the same package directory that
12+
// the CLI command belonged to.
13+
//
14+
// - QUnit is installed both as local dependency in the current project,
15+
// and also globally installed via npm by the end-user.
16+
// If the user (accidentally) ran the CLI command from their global
17+
// install, then we prefer to stil use the qunit library file from the
18+
// current project's dependency.
719
// eslint-disable-next-line node/no-missing-require
820
const localQUnitPath = resolve( "qunit", {
921

@@ -14,24 +26,25 @@ module.exports = function requireQUnit( resolve = require.resolve ) {
1426
delete require.cache[ localQUnitPath ];
1527
return require( localQUnitPath );
1628
} catch ( e ) {
17-
try {
29+
if ( e.code === "MODULE_NOT_FOUND" ) {
1830

19-
// Second, we use the globally installed QUnit
20-
// eslint-disable-next-line node/no-unpublished-require, node/no-missing-require
31+
// For:
32+
//
33+
// - QUnit is installed globally via npm by the end-user, and the
34+
// the user ran this global CLI command in a project directory that
35+
// does not have a qunit dependency installed.
36+
// Use the library file relative to the global CLI command in that case.
37+
//
38+
// - We are running a local command from within the source directory
39+
// of the QUnit project itself (e.g. qunit Git repository).
40+
// Use the library file relative to this command, within the source directory.
41+
//
42+
// eslint-disable-next-line node/no-missing-require, node/no-unpublished-require
2143
delete require.cache[ resolve( "../../qunit/qunit" ) ];
2244
// eslint-disable-next-line node/no-missing-require, node/no-unpublished-require
2345
return require( "../../qunit/qunit" );
24-
} catch ( e ) {
25-
if ( e.code === "MODULE_NOT_FOUND" ) {
26-
27-
// Finally, we use the local development version of QUnit
28-
// eslint-disable-next-line node/no-unpublished-require, node/no-missing-require
29-
delete require.cache[ resolve( "../../dist/qunit" ) ];
30-
// eslint-disable-next-line node/no-missing-require, node/no-unpublished-require
31-
return require( "../../dist/qunit" );
32-
}
33-
34-
throw e;
3546
}
47+
48+
throw e;
3649
}
3750
};

test/amd.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8">
55
<title>QUnit AMD Test Suite</title>
6-
<link rel="stylesheet" href="../dist/qunit.css">
6+
<link rel="stylesheet" href="../qunit/qunit.css">
77
<script src="../node_modules/requirejs/require.js"></script>
88
</head>
99
<body>
@@ -13,7 +13,7 @@
1313

1414
require.config( {
1515
paths: {
16-
qunit: "../dist/qunit"
16+
qunit: "../qunit/qunit"
1717
}
1818
} );
1919

test/autostart.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
<head>
44
<meta charset="UTF-8">
55
<title>QUnit Autostart Test Suite</title>
6-
<link rel="stylesheet" href="../dist/qunit.css">
6+
<link rel="stylesheet" href="../qunit/qunit.css">
77
</head>
88
<body>
99
<div id="qunit"></div>
10-
<script src="../dist/qunit.js"></script>
10+
<script src="../qunit/qunit.js"></script>
1111
<script>
1212
window.times = {};
1313

0 commit comments

Comments
 (0)