Skip to content

Commit 0a9999a

Browse files
authored
Install release tools with npm rather than via pre-commit hook (#666)
Previously mocha, uglifyjs and jshint used when publishing a new version were ensured / installed by `Rakefile` via the pre-commit git hook. Those modules were automatically installed globally if not present in `$PATH`. Installing modules globally has one particular downside that we should avoid: we can't ensure developers publishing new mustache.js versions have the same version of these 3rd party modules installed. If instead we make these modules local dev dependencies, we can ensure which versions are installed, and we make 3rd party dependencies explicit by listing them in `package.json`, rather than in `Rakefile`.
1 parent 28ca619 commit 0a9999a

File tree

3 files changed

+5
-20
lines changed

3 files changed

+5
-20
lines changed

Rakefile

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,19 @@ def minified_file
77
ENV['FILE'] || 'mustache.min.js'
88
end
99

10-
task :install_mocha do
11-
sh "npm install -g mocha" if `which mocha`.empty?
12-
end
13-
14-
task :install_uglify do
15-
sh "npm install -g uglify-js" if `which uglifyjs`.empty?
16-
end
17-
18-
task :install_jshint do
19-
sh "npm install -g jshint" if `which jshint`.empty?
20-
end
21-
2210
desc "Run all tests"
2311
task :test => :install_mocha do
24-
sh "mocha test"
12+
sh "./node_modules/.bin/mocha test"
2513
end
2614

2715
desc "Make a compressed build in #{minified_file}"
2816
task :minify => :install_uglify do
29-
sh "uglifyjs mustache.js > #{minified_file}"
17+
sh "./node_modules/.bin/uglifyjs mustache.js > #{minified_file}"
3018
end
3119

3220
desc "Run JSHint"
3321
task :hint => :install_jshint do
34-
sh "jshint mustache.js"
22+
sh "./node_modules/.bin/jshint mustache.js"
3523
end
3624

3725
# Creates a task that uses the various template wrappers to make a wrapped

hooks/pre-commit

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,6 @@ class Bumper
7272
def did_bump
7373
if !@bumped
7474
puts 'bump detected!'
75-
if `which uglifyjs`.empty?
76-
puts_c 31, 'you need uglifyjs installed'
77-
puts 'run `sudo npm install -g uglify-js`'
78-
exit 1
79-
end
8075
end
8176
@bumped = true
8277
end

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242
"devDependencies": {
4343
"chai": "^3.4.0",
4444
"eslint": "^2.5.1",
45+
"jshint": "^2.9.5",
4546
"mocha": "^3.0.2",
47+
"uglify-js": "^3.4.6",
4648
"zuul": "^3.11.0"
4749
},
4850
"spm": {

0 commit comments

Comments
 (0)