Skip to content

Commit

Permalink
chore: replace init scripts with a dependency on itself (#3674)
Browse files Browse the repository at this point in the history
This has the same result (symlink to the `karma` in the node_modules), but has two benefits:

- karma developers don't need to run extra command
- no peer dependency warnings when `npm install` is run
  • Loading branch information
devoto13 authored Apr 12, 2021
1 parent d0fad69 commit cc9420d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 39 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@ jobs:
include:
- node_js: "10"
script:
- npm run init
- npm run test:unit
- npm run test:e2e

- node_js: "12"
script:
- npm run init
- npm run test:unit
- npm run test:e2e

- node_js: "14"
script:
- npm run init
- if [[ "$TRAVIS_BRANCH" != "master" ]]; then
commitlint-travis;
fi;
Expand Down
3 changes: 0 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ install:
# Install our package dependencies
- appveyor-retry npm install

# Install our current directory as a dependency of itself
- npm run init:windows

test_script:
- npm run test:unit
- npm run test:client
Expand Down
6 changes: 1 addition & 5 deletions docs/dev/02-making-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@ Here are some tips on how to set up a Karma workspace and how to send a good pul
$ git clone https://github.com/<your-username>/karma.git
$ cd karma
```
* Install for development. Use a recent npm version, ignore peerdep warnings
* Install for development
```bash
$ npm install
$ npm run init
# or if you're on Windows
$ npm run init:windows
```

## Testing and Building
Expand Down
29 changes: 29 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@
"http2": "^3.3.6",
"husky": "^4.2.5",
"jasmine-core": "^3.6.0",
"karma": ".",
"karma-browserify": "^7.0.0",
"karma-browserstack-launcher": "^1.6.0",
"karma-chai": "^0.1.0",
Expand Down Expand Up @@ -509,10 +510,6 @@
"build:check": "node scripts/client.js check",
"build:watch": "node scripts/client.js watch",
"test:integration": "./scripts/integration-tests.sh",
"link": "node --eval \"path=require('path'); require('fs').symlinkSync(path.resolve(__dirname), path.resolve(__dirname, 'node_modules', 'karma'), 'junction')\"",
"unlink": "node --eval \"require('fs').unlinkSync(require('path').resolve(__dirname, 'node_modules', 'karma'))\"",
"init": "rm -rf node_modules/karma && cd node_modules && ln -nsf ../ karma && cd ../",
"init:windows": "(IF EXIST node_modules\\karma (rmdir node_modules\\karma /S /q)) && npm run link",
"semantic-release": "semantic-release"
}
}
24 changes: 0 additions & 24 deletions test/client/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const fs = require('fs')

const TRAVIS_WITH_BS = !!process.env.BROWSER_STACK_ACCESS_KEY

const launchers = {
Expand Down Expand Up @@ -37,28 +35,6 @@ const launchers = {
}
}

// Verify the install. This will run async but that's ok we'll see the log.
fs.lstat('node_modules/karma', (err, stats) => {
if (err) {
console.error('Cannot verify installation', err.stack || err)
}
if (stats && stats.isSymbolicLink()) {
return
}

console.log('**** Incorrect directory layout for karma self-tests ****')
console.log(`
$ npm install
$ npm run init
# or if you're on Windows
$ npm run init:windows
$ npm run build
`)
process.exit(1)
})

let browsers = ['Chrome']

if (process.env.TRAVIS) {
Expand Down

0 comments on commit cc9420d

Please sign in to comment.