UNPKG

1.57 kBtext/coffeescriptView Raw
1execSync = require('child_process').execSync
2expect = require('expect.js')
3path = require('path')
4IDIR = path.join(__dirname, 'cli')
5ODIR = path.join(__dirname, 'cliout')
6require('rimraf').sync(ODIR)
7fs = require('fs')
8compiler = require('../src/compiler')
9
10describe '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