@@ -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 (
915tutorialPj :PackageJson , dir :string
1016) :Tutorial . Config {
1117// package.json: name, config
1218const { config, name} = tutorialPj ;
1319const repo = configRepo ( tutorialPj . repo ) ;
14- const tutorialDir :string = join ( dir , 'node_modules' , name , config . dir ) ;
1520const runner :string = config . runner ;
1621const runnerOptions :Object = config . runnerOptions || { } ;
1722const configEdit = tutorialPj . config . edit ;
@@ -23,18 +28,24 @@ export function tutorialConfig(
2328}
2429
2530return {
26- dir :tutorialDir ,
31+ dir :join ( dir , 'node_modules' , name , config . dir ) ,
2732 runner,
2833 runnerOptions,
2934run :getRunner . run ,
3035load :getRunner . load ,
31- testSuffix :configTestSuffix ( config . testSuffix ) ,
36+ testSuffix :configTestSuffix ( config . testSuffix || 'js' ) ,
3237issuesPath :configIssuesPath ( tutorialPj . bugs ) ,
3338 repo,
3439edit :! ! 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 ) {
3950return suffix . length && suffix [ 0 ] === '.' ?suffix :'.' + suffix || null ;
4051}