Permalink
Browse files

Test projects that are known to follow JSS

Clones several projects that are known to follow "JavaScript Standard
Style" and runs the `standard` style checker to verify that it passes
without warnings. This helps ensure we don't accidentally introduce new
style rules that cause previously "good" code to start failing with new
warnings!
  • Loading branch information...
1 parent b1c0662 commit a1c73a41e87dd68f644a8798469e33dc55ce1a5e @feross committed Jan 28, 2015
Showing with 64 additions and 2 deletions.
  1. +2 −0 .gitignore
  2. +56 −0 bin/test.js
  3. +6 −2 package.json
View
@@ -0,0 +1,2 @@
+node_modules/
+tmp/
View
@@ -0,0 +1,56 @@
+#!/usr/bin/env node
+
+/**
+ * Clones several projects that are known to follow "JavaScript Standard Style" and runs
+ * the `standard` style checker to verify that it passes without warnings. This helps
+ * ensure we don't accidentally introduce new style rules that cause previously "good"
+ * code to start failing with new warnings!
+ */
+
+var cp = require('child_process')
+var mkdirp = require('mkdirp')
+var path = require('path')
+var rimraf = require('rimraf')
+var series = require('run-series')
+
+var TMP = path.join(__dirname, '..', 'tmp')
+var STANDARD = path.join(__dirname, 'cmd.js')
+
+var URLS = [
+ 'git@github.com:feross/webtorrent.git',
+ 'git@github.com:feross/bittorrent-tracker.git',
+ 'git@github.com:feross/bittorrent-dht.git'
+]
+
+rimraf.sync(TMP)
+mkdirp.sync(TMP)
+
+series(URLS.map(function (url) {
+ return function (cb) {
+ var name = /\/([^.]+)\.git$/.exec(url)[1]
+ var args = [ 'clone', url, path.join(TMP, name) ]
+ // TODO: Start `git` in a way that works on Windows – PR welcome!
+ spawn('git', args, cb)
+ }
+}), function (err) {
+ if (err) return error(err)
+ spawn(STANDARD, [], function (err) {
+ if (err) return error(err)
+ console.log('ok')
+ })
+})
+
+function spawn (command, args, cb) {
+ var child = cp.spawn(command, args, { stdio: 'inherit' })
+ child.on('error', error)
+ child.on('close', function (code) {
+ if (code !== 0) cb(new Error('non-zero exit code: ' + code))
+ else cb(null)
+ })
+ return child
+}
+
+function error (err) {
+ console.error(err.stack || err.message || err)
+ process.exit(1)
+}
View
@@ -21,7 +21,11 @@
"minimatch": "^2.0.1",
"split": "^0.3.2"
},
- "devDependencies": {},
+ "devDependencies": {
+ "mkdirp": "^0.5.0",
+ "rimraf": "^2.2.8",
+ "run-series": "^1.0.2"
+ },
"homepage": "https://github.com/feross/standard",
"keywords": [
"policy",
@@ -47,6 +51,6 @@
"url": "git://github.com/feross/standard.git"
},
"scripts": {
- "test": "node ./bin/cmd.js"
+ "test": "node ./bin/test.js"
}
}

0 comments on commit a1c73a4

Please sign in to comment.