Created
January 29, 2014 14:54
-
-
Save jacaetevha/8689681 to your computer and use it in GitHub Desktop.
Given an exercism.io directory for JavaScript, edit the given spec file, create a test directory, and write the necessary node.js files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cat <<HERE > `pwd`/package.json | |
{ | |
"dependencies": { | |
"underscore": "*" | |
}, | |
"devDependencies": { | |
"jasmine-node": "*" | |
} | |
} | |
HERE | |
cat <<HERE > `pwd`/Makefile | |
test: | |
@./node_modules/.bin/jasmine-node test | |
.PHONY: test | |
HERE | |
mkdir -p test | |
filename=`grep require *.spec.js | cut -d'(' -f2 | cut -d ')' -f1 | cut -d"'" -f2 | cut -d"/" -f2`.js | |
cat <<HERE >$filename | |
var _ = require('underscore'); | |
function renameMe(){} | |
module.exports = renameMe; | |
HERE | |
mv *.spec.js test | |
cd test | |
pattern='require(\.\/' | |
replace='require(\.\/\.\.\/' | |
echo | |
echo 'updating spec file' | |
echo | |
spec=`ls *.spec.js` | |
ed -s $spec <<< $'H\n/require/\ns/\./.\/../\n,wq' | |
cd .. | |
npm install | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment