@@ -5,13 +5,18 @@ import configRunner from './config-runner';
55import { isWindows } from './system' ;
66import fileExists from 'node-file-exists' ;
77
8+ /**
9+ * capture configuration variables
10+ * @param {PackageJson } tutorialPj tutorial package.json
11+ * @param {string } dir use directory
12+ * @returns Tutorial.Config
13+ */
814export function tutorialConfig (
915 tutorialPj : PackageJson , dir : string
1016) : Tutorial . Config {
1117 // package.json: name, config
1218 const { config, name} = tutorialPj ;
1319 const repo = configRepo ( tutorialPj . repo ) ;
14- const tutorialDir : string = join ( dir , 'node_modules' , name , config . dir ) ;
1520 const runner : string = config . runner ;
1621 const runnerOptions : Object = config . runnerOptions || { } ;
1722 const configEdit = tutorialPj . config . edit ;
@@ -23,18 +28,24 @@ export function tutorialConfig(
2328 }
2429
2530 return {
26- dir : tutorialDir ,
31+ dir : join ( dir , 'node_modules' , name , config . dir ) ,
2732 runner,
2833 runnerOptions,
2934 run : getRunner . run ,
3035 load : getRunner . load ,
31- testSuffix : configTestSuffix ( config . testSuffix ) ,
36+ testSuffix : configTestSuffix ( config . testSuffix || 'js' ) ,
3237 issuesPath : configIssuesPath ( tutorialPj . bugs ) ,
3338 repo,
3439 edit : ! ! repo && configEdit || false ,
3540 } ;
3641}
3742
43+ /**
44+ * add test suffix to the end of files
45+ * example: '.js' -> '.js'
46+ * example: 'js' -> '.js'
47+ * @param {string } suffix
48+ */
3849function configTestSuffix ( suffix : string ) {
3950 return suffix . length && suffix [ 0 ] === '.' ? suffix : '.' + suffix || null ;
4051}
0 commit comments