Skip to content

Commit 3f1c6d0

Browse files
committed
Compile JavaScript, so CoffeeScript is not need at runtime
Fixes #8
1 parent 0e5c505 commit 3f1c6d0

4 files changed

Lines changed: 23 additions & 7 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
2+
lib/
23
.DS_Store

Gruntfile.coffee

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ module.exports = ->
33
@initConfig
44
pkg: @file.readJSON 'package.json'
55

6+
# CoffeeScript compilation
7+
coffee:
8+
library:
9+
expand: true
10+
cwd: 'src'
11+
src: ['**.coffee']
12+
dest: 'lib'
13+
ext: '.js'
14+
615
# BDD tests on Node.js
716
mochaTest:
817
nodejs:
@@ -36,6 +45,7 @@ module.exports = ->
3645
@loadNpmTasks 'grunt-mocha-test'
3746
@loadNpmTasks 'grunt-coffeelint'
3847
@loadNpmTasks 'grunt-shell-spawn'
48+
@loadNpmTasks 'grunt-contrib-coffee'
3949

4050
# Our local tasks
4151
@registerTask 'fbp-test', [
@@ -44,8 +54,7 @@ module.exports = ->
4454
'shell:msgflo:kill'
4555
]
4656

47-
@registerTask 'build', 'Build the chosen target platform', (target = 'all') =>
48-
# nothing
57+
@registerTask 'build', 'Build the chosen target platform', ['coffee']
4958

5059
@registerTask 'test', 'Build and run automated tests', (target = 'all') =>
5160
@task.run 'coffeelint'

index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
require('coffee-script/register');
2-
module.exports = require('./src/');
1+
try {
2+
// Compiled JavaScript first
3+
module.exports = require('./lib/');
4+
} catch (e) {
5+
require('coffee-script/register');
6+
module.exports = require('./src/');
7+
}

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"dependencies": {
2020
"async": "^0.9.0",
2121
"chance": "^0.7.3",
22-
"coffee-script": "^1.8.0",
2322
"commander": "^2.6.0",
2423
"debug": "^2.1.2",
2524
"fbp": "^1.1.2",
@@ -28,13 +27,15 @@
2827
},
2928
"devDependencies": {
3029
"amqplib": "^0.3.0",
31-
"mqtt": "1.4.x",
3230
"chai": "~1.9.0",
3331
"grunt": "~0.4.1",
32+
"coffee-script": "^1.8.0",
3433
"grunt-coffeelint": "~0.0.6",
34+
"grunt-contrib-coffee": "^1.0.0",
3535
"grunt-mocha-test": "^0.12.2",
3636
"grunt-shell-spawn": "^0.3.1",
37-
"mocha": "~1.21.0"
37+
"mocha": "~1.21.0",
38+
"mqtt": "1.4.x"
3839
},
3940
"keywords": [],
4041
"bin": {

0 commit comments

Comments
 (0)