1 | execSync = require('child_process').execSync
|
2 | expect = require('expect.js')
|
3 | path = require('path')
|
4 | IDIR = path.join(__dirname, 'cli')
|
5 | ODIR = path.join(__dirname, 'cliout')
|
6 | require('rimraf').sync(ODIR)
|
7 | fs = require('fs')
|
8 | compiler = require('../src/compiler')
|
9 |
|
10 | describe 'cmd', ->
|
11 | it 'transforms a single file', ->
|
12 | CMD="mfjsc #{path.join(IDIR,'test1-in.js')} --transform.packageVar=KK --transform.start=minimal -o #{ODIR}"
|
13 | execSync(CMD)
|
14 | expect(compiler.print(fs.readFileSync(path.join(IDIR,'test1-out.js'),'utf-8')))
|
15 | .to.equal(compiler.print(fs.readFileSync(path.join(ODIR,'test1-in.js'),'utf-8')))
|
16 | CMD="mfjsc #{path.join(IDIR,'test1-in.js')} --transform.packageVar=KK --transform.start=minimal --dest=#{ODIR}/res1.js"
|
17 | execSync(CMD)
|
18 | expect(compiler.print(fs.readFileSync(path.join(IDIR,'test1-out.js'),'utf-8')))
|
19 | .to.equal(compiler.print(fs.readFileSync(path.join(ODIR,'res1.js'),'utf-8')))
|
20 | CMD="mfjsc #{path.join(IDIR,'test1-in.js')} --transform.packageVar=KK --transform.start=minimal --dest=res3.js -o #{ODIR}"
|
21 | execSync(CMD)
|
22 | expect(compiler.print(fs.readFileSync(path.join(IDIR,'test1-out.js'),'utf-8')))
|
23 | .to.equal(compiler.print(fs.readFileSync(path.join(ODIR,'res3.js'),'utf-8')))
|
24 | CMD="mfjsc --transform.packageVar=KK --transform.start=minimal < #{path.join(IDIR,'test1-in.js')} > #{ODIR}/res2.js"
|
25 | execSync(CMD)
|
26 | expect(compiler.print(fs.readFileSync(path.join(IDIR,'test1-out.js'),'utf-8')))
|
27 | .to.equal(compiler.print(fs.readFileSync(path.join(ODIR,'res2.js'),'utf-8')))
|
28 |
|