@@ -4,7 +4,6 @@ let cli = require('../../src/cli')
44let { join, resolve } = require ( 'path' )
55let { readFileSync, existsSync, rmSync, mkdirSync } = require ( 'fs' )
66let tmp = resolve ( __dirname , '..' , 'tmp' )
7- let origCwd = process . cwd ( )
87let argv = process . argv
98let args = s => process . argv = [ 'fake-env' , 'fake-file' , ...s . split ( ' ' ) ]
109
@@ -23,64 +22,39 @@ describe('CLI Integration Tests', () => {
2322 } )
2423
2524 beforeEach ( ( ) => {
26- // Clean tmp directory before each test but stay in original directory
25+ // Clean tmp directory before each test
2726 emptyDirSync ( tmp )
2827 } )
2928
3029 it ( 'should build the basic templated node runtime project' , async ( ) => {
31- process . chdir ( tmp )
32- try {
33- args ( '--no-install --runtime node.js' )
34- await cli ( )
35- assert . ok ( existsSync ( join ( tmp , 'src' , 'http' , 'get-index' , 'index.mjs' ) ) , 'src/http/get-index/index.mjs created' )
36- assert . ok ( readFileSync ( join ( tmp , 'app.arc' ) , 'utf-8' ) . match ( / r u n t i m e n o d e / ) , '"runtime node" present somewhere in manifest' )
37- }
38- finally {
39- process . chdir ( origCwd )
40- }
30+ args ( `--no-install --runtime node.js ${ tmp } ` )
31+ await cli ( )
32+ assert . ok ( existsSync ( join ( tmp , 'src' , 'http' , 'get-index' , 'index.mjs' ) ) , 'src/http/get-index/index.mjs created' )
33+ assert . ok ( readFileSync ( join ( tmp , 'app.arc' ) , 'utf-8' ) . match ( / r u n t i m e n o d e / ) , '"runtime node" present somewhere in manifest' )
4134 } )
4235
4336 it ( 'should build the basic templated deno runtime project' , async ( ) => {
44- process . chdir ( tmp )
45- try {
46- args ( '--no-install --runtime deno' )
47- await cli ( )
48- assert . ok ( existsSync ( join ( tmp , 'src' , 'http' , 'get-index' , 'mod.ts' ) ) , 'src/http/get-index/mod.ts created' )
49- assert . ok ( readFileSync ( join ( tmp , 'app.arc' ) , 'utf-8' ) . match ( / r u n t i m e d e n o / ) , '"runtime deno" present somewhere in manifest' )
50- }
51- finally {
52- process . chdir ( origCwd )
53- }
37+ args ( `--no-install --runtime deno ${ tmp } ` )
38+ await cli ( )
39+ assert . ok ( existsSync ( join ( tmp , 'src' , 'http' , 'get-index' , 'mod.ts' ) ) , 'src/http/get-index/mod.ts created' )
40+ assert . ok ( readFileSync ( join ( tmp , 'app.arc' ) , 'utf-8' ) . match ( / r u n t i m e d e n o / ) , '"runtime deno" present somewhere in manifest' )
5441 } )
5542
5643 it ( 'should build the basic templated python runtime project' , async ( ) => {
57- process . chdir ( tmp )
58- try {
59- args ( '--no-install --runtime python' )
60- await cli ( )
61- assert . ok ( existsSync ( join ( tmp , 'src' , 'http' , 'get-index' , 'lambda.py' ) ) , 'src/http/get-index/lambda.py created' )
62- assert . ok ( readFileSync ( join ( tmp , 'app.arc' ) , 'utf-8' ) . match ( / r u n t i m e p y t h o n / ) , '"runtime python" present somewhere in manifest' )
63- }
64- finally {
65- process . chdir ( origCwd )
66- }
44+ args ( `--no-install --runtime python ${ tmp } ` )
45+ await cli ( )
46+ assert . ok ( existsSync ( join ( tmp , 'src' , 'http' , 'get-index' , 'lambda.py' ) ) , 'src/http/get-index/lambda.py created' )
47+ assert . ok ( readFileSync ( join ( tmp , 'app.arc' ) , 'utf-8' ) . match ( / r u n t i m e p y t h o n / ) , '"runtime python" present somewhere in manifest' )
6748 } )
6849
6950 it ( 'should build the basic templated ruby runtime project' , async ( ) => {
70- process . chdir ( tmp )
71- try {
72- args ( '--no-install --runtime ruby' )
73- await cli ( )
74- assert . ok ( existsSync ( join ( tmp , 'src' , 'http' , 'get-index' , 'lambda.rb' ) ) , 'src/http/get-index/lambda.rb created' )
75- assert . ok ( readFileSync ( join ( tmp , 'app.arc' ) , 'utf-8' ) . match ( / r u n t i m e r u b y / ) , '"runtime ruby" present somewhere in manifest' )
76- }
77- finally {
78- process . chdir ( origCwd )
79- }
51+ args ( `--no-install --runtime ruby ${ tmp } ` )
52+ await cli ( )
53+ assert . ok ( existsSync ( join ( tmp , 'src' , 'http' , 'get-index' , 'lambda.rb' ) ) , 'src/http/get-index/lambda.rb created' )
54+ assert . ok ( readFileSync ( join ( tmp , 'app.arc' ) , 'utf-8' ) . match ( / r u n t i m e r u b y / ) , '"runtime ruby" present somewhere in manifest' )
8055 } )
8156
8257 after ( ( ) => {
8358 process . argv = argv
84- process . chdir ( origCwd )
8559 } )
8660} )
0 commit comments