@@ -5,8 +5,8 @@ const execa = require('execa');
5
5
const pathExists = require ( 'path-exists' ) ;
6
6
const readPkg = require ( 'read-pkg' ) ;
7
7
const copy = require ( 'cpy' ) ;
8
- const tempwrite = require ( 'temp-write' ) ;
9
8
const tempfile = require ( 'tempfile' ) ;
9
+ const cli = path . resolve ( '../cli.js' ) ;
10
10
11
11
function read ( pathFile ) {
12
12
return new Promise ( ( resolve , reject ) => {
@@ -20,55 +20,55 @@ function read(pathFile) {
20
20
}
21
21
22
22
test ( 'Missing required arguments -i, -o' , t => {
23
- t . throws ( execa ( '../ cli.js' , [ ] ) ) ;
23
+ t . throws ( execa ( cli , [ ] ) ) ;
24
24
} ) ;
25
25
26
26
test ( 'Missing required arguments -o' , t => {
27
- t . throws ( execa ( '../ cli.js' , [ '-i' , 'fixtures/input.html' ] ) ) ;
27
+ t . throws ( execa ( cli , [ '-i' , 'fixtures/input.html' ] ) ) ;
28
28
} ) ;
29
29
30
30
test ( 'Missing required arguments -i' , t => {
31
- const filename = tempwrite . sync ( 'output .html') ;
32
- t . throws ( execa ( '../ cli.js' , [ '-o' , filename ] ) ) ;
31
+ const filename = tempfile ( ' .html') ;
32
+ t . throws ( execa ( cli , [ '-o' , filename ] ) ) ;
33
33
} ) ;
34
34
35
35
test ( 'One of the arguments' , t => {
36
- const filename = tempwrite . sync ( 'output .html') ;
37
- t . throws ( execa ( '../ cli.js' , [ '-o' , filename , '-r' , '-i' , 'fixtures/input.html' ] ) ) ;
36
+ const filename = tempfile ( ' .html') ;
37
+ t . throws ( execa ( cli , [ '-o' , filename , '-r' , '-i' , 'fixtures/input.html' ] ) ) ;
38
38
} ) ;
39
39
40
40
test ( 'Check version' , async t => {
41
- t . is ( ( await execa ( '../ cli.js' , [ '-v' ] ) ) . stdout , ( await readPkg ( path . dirname ( __dirname ) ) ) . version ) ;
41
+ t . is ( ( await execa ( cli , [ '-v' ] ) ) . stdout , ( await readPkg ( path . dirname ( __dirname ) ) ) . version ) ;
42
42
} ) ;
43
43
44
44
test ( 'Transform html witch config in package.json' , async t => {
45
45
t . plan ( 2 ) ;
46
- const filename = await tempwrite ( '' , 'output .html') ;
47
- await execa ( '../ cli.js' , [ '-i' , 'fixtures/input.html' , '-o' , filename ] ) ;
46
+ const filename = tempfile ( ' .html') ;
47
+ await execa ( cli , [ '-i' , 'fixtures/input.html' , '-o' , filename ] ) ;
48
48
t . true ( await pathExists ( filename ) ) ;
49
49
t . is ( ( await read ( 'expected/output-config-pkg.html' ) ) , ( await read ( filename ) ) ) ;
50
50
} ) ;
51
51
52
52
test ( 'Transform html witch indent' , async t => {
53
53
t . plan ( 2 ) ;
54
- const filename = await tempwrite ( '' , 'output .html') ;
55
- await execa ( '../ cli.js' , [ '-i' , 'fixtures/input-indent.html' , '-o' , filename ] ) ;
54
+ const filename = tempfile ( ' .html') ;
55
+ await execa ( cli , [ '-i' , 'fixtures/input-indent.html' , '-o' , filename ] ) ;
56
56
t . true ( await pathExists ( filename ) ) ;
57
57
t . is ( ( await read ( 'expected/output-indent.html' ) ) , ( await read ( filename ) ) ) ;
58
58
} ) ;
59
59
60
60
test ( 'Transform html witch config in file' , async t => {
61
61
t . plan ( 2 ) ;
62
- const filename = await tempwrite ( '' , 'output .html') ;
63
- await execa ( '../ cli.js' , [ '-i' , 'fixtures/input.html' , '-o' , filename , '-c' , 'fixtures/config.json' ] ) ;
62
+ const filename = tempfile ( ' .html') ;
63
+ await execa ( cli , [ '-i' , 'fixtures/input.html' , '-o' , filename , '-c' , 'fixtures/config.json' ] ) ;
64
64
t . true ( await pathExists ( filename ) ) ;
65
65
t . is ( ( await read ( 'expected/output-config-file.html' ) ) , ( await read ( filename ) ) ) ;
66
66
} ) ;
67
67
68
68
test ( 'Transform html from folder' , async t => {
69
69
t . plan ( 2 ) ;
70
70
const folder = await tempfile ( ) ;
71
- await execa ( '../ cli.js' , [ '-i' , 'fixtures/*.html' , '-o' , `${ folder } /` ] ) ;
71
+ await execa ( cli , [ '-i' , 'fixtures/*.html' , '-o' , `${ folder } /` ] ) ;
72
72
t . is ( ( await read ( 'expected/output-config-pkg.html' ) ) , ( await read ( `${ folder } /input.html` ) ) ) ;
73
73
t . is ( ( await read ( 'expected/output-indent.html' ) ) , ( await read ( `${ folder } /input-indent.html` ) ) ) ;
74
74
} ) ;
@@ -77,15 +77,15 @@ test('Transform html witch options replace', async t => {
77
77
t . plan ( 2 ) ;
78
78
const folder = await tempfile ( ) ;
79
79
await copy ( [ 'fixtures/*.html' ] , `${ folder } /` ) ;
80
- await execa ( '../ cli.js' , [ '-i' , `${ folder } /*.html` , '-r' ] ) ;
80
+ await execa ( cli , [ '-i' , `${ folder } /*.html` , '-r' ] ) ;
81
81
t . is ( ( await read ( 'expected/output-config-pkg.html' ) ) , ( await read ( `${ folder } /input.html` ) ) ) ;
82
82
t . is ( ( await read ( 'expected/output-indent.html' ) ) , ( await read ( `${ folder } /input-indent.html` ) ) ) ;
83
83
} ) ;
84
84
85
85
test ( 'Transform html witch config in file and stdin options use' , async t => {
86
86
t . plan ( 2 ) ;
87
- const filename = await tempwrite ( '' , 'output .html') ;
88
- await execa ( '../ cli.js' , [
87
+ const filename = tempfile ( ' .html') ;
88
+ await execa ( cli , [
89
89
'-o' ,
90
90
filename ,
91
91
'-i' ,
0 commit comments