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