1 | coffeemill = require '../lib/coffeemill'
|
2 | {Relay} = require 'relay'
|
3 | path = require 'path'
|
4 | fs = require 'fs'
|
5 | {spawn} = require 'child_process'
|
6 |
|
7 | INPUT = path.join __dirname, 'input'
|
8 | OUTPUT = path.join __dirname, 'output'
|
9 |
|
10 | pickUpAfter = ->
|
11 | process.nextTick ->
|
12 | Relay.serial(
|
13 | Relay.func(->
|
14 | fs.readdir OUTPUT, @next
|
15 | )
|
16 | Relay.func((err, files)->
|
17 | if err?
|
18 | @skip()
|
19 | else
|
20 | @next files
|
21 | )
|
22 | Relay.each(
|
23 | Relay.func((file)->
|
24 | fs.unlink path.join(OUTPUT, file), @next
|
25 | )
|
26 | )
|
27 | )
|
28 | .complete(->
|
29 | process.exit 0
|
30 | )
|
31 | .start()
|
32 |
|
33 | exports.direct =
|
34 |
|
35 | 'normal': (test)->
|
36 | coffeemill.grind {
|
37 | input : INPUT
|
38 | output: OUTPUT
|
39 | silent: true
|
40 | }, ->
|
41 | fs.readFile path.join(OUTPUT, 'dummy.js'), 'utf8', (err, data)->
|
42 | test.strictEqual err, null
|
43 | test.strictEqual data, """
|
44 | (function() {
|
45 | var foo;
|
46 |
|
47 | foo = 'dummy';
|
48 |
|
49 | }).call(this);
|
50 |
|
51 | """
|
52 | test.done()
|
53 |
|
54 | 'bare': (test)->
|
55 | coffeemill.grind {
|
56 | input : INPUT
|
57 | output: OUTPUT
|
58 | bare : true
|
59 | silent: true
|
60 | }, ->
|
61 | fs.readFile path.join(OUTPUT, 'dummy.js'), 'utf8', (err, data)->
|
62 | test.strictEqual err, null
|
63 | test.strictEqual data, """
|
64 | var foo;
|
65 |
|
66 | foo = 'dummy';
|
67 |
|
68 | """
|
69 | test.done()
|
70 |
|
71 | 'compress': (test)->
|
72 | coffeemill.grind {
|
73 | input : INPUT
|
74 | output: OUTPUT
|
75 | minify: true
|
76 | silent: true
|
77 | }, ->
|
78 | fs.readFile path.join(OUTPUT, 'dummy.min.js'), 'utf8', (err, data)->
|
79 | test.strictEqual err, null
|
80 | test.strictEqual data, """
|
81 | (function(){var a;a="dummy"}).call(this)
|
82 | """
|
83 | test.done()
|
84 | pickUpAfter()
|