Skip to content

Commit

Permalink
Setup tests on CircleCI (#6)
Browse files Browse the repository at this point in the history
* Add script for installing peer dependecies
See yarnpkg/yarn#1503

* Add test configuration

* Fix eslint errors and warnings

* Add workflow to CircleCI config

* Use node 10 image

* Remove `yarn` from test script
  • Loading branch information
misogl committed Nov 9, 2018
1 parent e98e21d commit 9acd9cd
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 5 deletions.
32 changes: 32 additions & 0 deletions .circleci/config.yml
@@ -0,0 +1,32 @@
version: 2
jobs:
test:
docker:
- image: circleci/node:10

steps:
- checkout
- restore_cache:
name: Restoring Yarn Cache
keys:
# Find a cache corresponding to this specific package.json checksum.
- v-yarn-{{ checksum "package.json" }}
# Find the most recent cache regardless of package.json checksum.
- v-yarn-
- run:
name: Installing All Dependencies
command: yarn install-peer
- save_cache:
name: Saving Yarn Cache
key: v-yarn-{{ checksum "package.json" }}
paths:
- node_modules
- run:
name: Running Tests
command: yarn test

workflows:
version: 2
test:
jobs:
- test
2 changes: 2 additions & 0 deletions .npmignore
@@ -1,3 +1,5 @@
extractPeerDeps.js
getPeerScript.js
src
webpack.config.js
yarn.lock
11 changes: 11 additions & 0 deletions getPeerScript.js
@@ -0,0 +1,11 @@
// returns a yarn command to re-add peer dependencies which as a side effect installs them into node_modules
const deps = require('./package').peerDependencies
const res = []
for (let dep in deps) {
res.push(`"${dep}@${deps[dep]}"`)
}

const depStr = res.join(' ')
if (depStr.length) {
process.stdout.write(`yarn add --peer --no-lockfile ${depStr}`)
}
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -4,10 +4,11 @@
"description": "Default Webpack 2 & 3 config we use in vacuumlabs.",
"main": "dist/index.js",
"scripts": {
"install-peer": "node ./getPeerScript.js | sh",
"build": "babel -d dist/ src/ && node ./extractPeerDeps.js",
"build-watch": "babel -d dist/ src/ --watch",
"prepublish": "npm run build",
"test": "echo \"Error: no test specified\" && exit 1",
"test": "eslint . --max-warnings 0",
"eslint": "eslint ."
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/output.js
@@ -1,7 +1,7 @@
export default function(options) {
return {
path: options.buildDir,
filename: options.useHashedAssetNames ? '[name].[hash].js': '[name].js',
filename: options.useHashedAssetNames ? '[name].[hash].js' : '[name].js',
chunkFilename: '[name]-[chunkhash].js',
publicPath: options.env === 'development'
? `http://${options.host}:${options.port}/`
Expand Down
2 changes: 1 addition & 1 deletion src/server.js
Expand Up @@ -2,7 +2,7 @@
import webpack from 'webpack'
import WebpackDevServer from 'webpack-dev-server'

export default (webpackConfig, options, done) =>
export default (webpackConfig, options, done) =>
new WebpackDevServer(webpack(webpackConfig), {
publicPath: webpackConfig.output.publicPath,
hot: true,
Expand Down
4 changes: 2 additions & 2 deletions src/styles.js
Expand Up @@ -48,6 +48,6 @@ export function plugins(options) {
return options.useDevServer
? []
: [new ExtractTextPlugin({
filename: options.useHashedAssetNames ? 'app.[contenthash].css' : 'app.css',
allChunks: true})]
filename: options.useHashedAssetNames ? 'app.[contenthash].css' : 'app.css',
allChunks: true})]
}

0 comments on commit 9acd9cd

Please sign in to comment.