@@ -5,13 +5,18 @@ import configRunner from './config-runner';
5
5
import { isWindows } from './system' ;
6
6
import fileExists from 'node-file-exists' ;
7
7
8
+ /**
9
+ * capture configuration variables
10
+ *@param {PackageJson } tutorialPj tutorial package.json
11
+ *@param {string } dir use directory
12
+ *@returns Tutorial.Config
13
+ */
8
14
export function tutorialConfig (
9
15
tutorialPj :PackageJson , dir :string
10
16
) :Tutorial . Config {
11
17
// package.json: name, config
12
18
const { config, name} = tutorialPj ;
13
19
const repo = configRepo ( tutorialPj . repo ) ;
14
- const tutorialDir :string = join ( dir , 'node_modules' , name , config . dir ) ;
15
20
const runner :string = config . runner ;
16
21
const runnerOptions :Object = config . runnerOptions || { } ;
17
22
const configEdit = tutorialPj . config . edit ;
@@ -23,18 +28,24 @@ export function tutorialConfig(
23
28
}
24
29
25
30
return {
26
- dir :tutorialDir ,
31
+ dir :join ( dir , 'node_modules' , name , config . dir ) ,
27
32
runner,
28
33
runnerOptions,
29
34
run :getRunner . run ,
30
35
load :getRunner . load ,
31
- testSuffix :configTestSuffix ( config . testSuffix ) ,
36
+ testSuffix :configTestSuffix ( config . testSuffix || 'js' ) ,
32
37
issuesPath :configIssuesPath ( tutorialPj . bugs ) ,
33
38
repo,
34
39
edit :! ! repo && configEdit || false ,
35
40
} ;
36
41
}
37
42
43
+ /**
44
+ * add test suffix to the end of files
45
+ * example: '.js' -> '.js'
46
+ * example: 'js' -> '.js'
47
+ *@param {string } suffix
48
+ */
38
49
function configTestSuffix ( suffix :string ) {
39
50
return suffix . length && suffix [ 0 ] === '.' ?suffix :'.' + suffix || null ;
40
51
}