@@ -4,7 +4,7 @@ import * as path from 'path';
4
4
import * as fs from 'fs' ;
5
5
import * as acorn from 'acorn' ;
6
6
7
- import { svelte , env , setupHtmlEqual } from './helpers.js' ;
7
+ import { addLineNumbers , loadConfig , svelte , env , setupHtmlEqual } from './helpers.js' ;
8
8
9
9
let showCompiledCode = false ;
10
10
let compileOptions = null ;
@@ -18,36 +18,13 @@ require.extensions[ '.html' ] = function ( module, filename ) {
18
18
return module . _compile ( code , filename ) ;
19
19
} ;
20
20
21
- function addLineNumbers ( code ) {
22
- return code . split ( '\n' ) . map ( ( line , i ) => {
23
- i = String ( i + 1 ) ;
24
- while ( i . length < 3 ) i = ` ${ i } ` ;
25
-
26
- return `${ i } : ${ line . replace ( / ^ \t + / , match => match . split ( '\t' ) . join ( ' ' ) ) } ` ;
27
- } ) . join ( '\n' ) ;
28
- }
29
-
30
- function loadConfig ( dir ) {
31
- try {
32
- const resolved = require . resolve ( `./generator/${ dir } /_config.js` ) ;
33
- delete require . cache [ resolved ] ;
34
- return require ( resolved ) . default ;
35
- } catch ( err ) {
36
- if ( err . code === 'E_NOT_FOUND' ) {
37
- return { } ;
38
- }
39
-
40
- throw err ;
41
- }
42
- }
43
-
44
21
describe ( 'generate' , ( ) => {
45
22
before ( setupHtmlEqual ) ;
46
23
47
24
function runTest ( dir , shared ) {
48
25
if ( dir [ 0 ] === '.' ) return ;
49
26
50
- const config = loadConfig ( dir ) ;
27
+ const config = loadConfig ( `./generator/ ${ dir } /_config.js` ) ;
51
28
52
29
if ( config . solo && process . env . CI ) {
53
30
throw new Error ( 'Forgot to remove `solo: true` from test' ) ;
0 commit comments