File tree Expand file tree Collapse file tree 7 files changed +42
-7
lines changed Expand file tree Collapse file tree 7 files changed +42
-7
lines changed Original file line number Diff line number Diff line change @@ -3,13 +3,14 @@ var fs_1 = require('fs');
3
3
var path_1 = require ( 'path' ) ;
4
4
var file_1 = require ( '../../tools/file' ) ;
5
5
var cleanup_1 = require ( './cleanup' ) ;
6
+ var settings_1 = require ( './settings' ) ;
6
7
function loadImport ( lines , pathToMd ) {
7
8
pathToMd = cleanup_1 . trimQuotes ( pathToMd ) ;
8
9
if ( ! pathToMd . match ( / \. m d $ / ) ) {
9
10
pathToMd = pathToMd . concat ( '.md' ) ;
10
11
}
11
- var realPath = path_1 . join ( process . cwd ( ) , pathToMd ) ;
12
- if ( ! file_1 . fileExists ( pathToMd ) ) {
12
+ var realPath = path_1 . join ( process . cwd ( ) , settings_1 . tutorialDir , pathToMd ) ;
13
+ if ( ! file_1 . fileExists ( realPath ) ) {
13
14
console . log ( 'Invalid path to markdown file' , realPath ) ;
14
15
return ;
15
16
}
Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+ var fs_1 = require ( 'fs' ) ;
3
+ var path_1 = require ( 'path' ) ;
4
+ var chalk_1 = require ( 'chalk' ) ;
5
+ var settings = null ;
6
+ try {
7
+ settings = JSON . parse ( fs_1 . readFileSync ( path_1 . join ( process . cwd ( ) , 'package.json' ) , 'utf8' ) ) ;
8
+ }
9
+ catch ( e ) {
10
+ console . log ( chalk_1 . red ( 'No package.json config found in directory ' , process . cwd ( ) , e ) ) ;
11
+ }
12
+ exports . tutorialDir = settings . dir || 'tutorial' ;
Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+ exports . tutorialDir = 'tutorial' ;
Original file line number Diff line number Diff line change @@ -2,14 +2,17 @@ import {readFileSync} from 'fs';
2
2
import { join } from 'path' ;
3
3
import { fileExists } from '../../tools/file' ;
4
4
import { trimQuotes } from './cleanup' ;
5
+ import { tutorialDir } from './settings' ;
5
6
6
7
export function loadImport ( lines : string [ ] , pathToMd : string ) : string [ ] {
8
+ // add .md suffix
7
9
pathToMd = trimQuotes ( pathToMd ) ;
8
10
if ( ! pathToMd . match ( / \. m d $ / ) ) {
9
11
pathToMd = pathToMd . concat ( '.md' ) ;
10
12
}
11
- let realPath : string = join ( process . cwd ( ) , pathToMd ) ;
12
- if ( ! fileExists ( pathToMd ) ) {
13
+ // get path to imports
14
+ let realPath : string = join ( process . cwd ( ) , tutorialDir , pathToMd ) ;
15
+ if ( ! fileExists ( realPath ) ) {
13
16
console . log ( 'Invalid path to markdown file' , realPath ) ;
14
17
return ;
15
18
}
Original file line number Diff line number Diff line change
1
+ import { readFileSync } from 'fs' ;
2
+ import { join } from 'path' ;
3
+ import { red } from 'chalk' ;
4
+
5
+ let settings = null ;
6
+ try {
7
+ settings = JSON . parse (
8
+ readFileSync (
9
+ join ( process . cwd ( ) , 'package.json' ) , 'utf8'
10
+ )
11
+ ) ;
12
+ } catch ( e ) {
13
+ console . log ( red ( 'No package.json config found in directory ' , process . cwd ( ) , e ) ) ;
14
+ }
15
+
16
+ export const tutorialDir = settings . dir || 'tutorial' ;
Original file line number Diff line number Diff line change @@ -13,10 +13,10 @@ program
13
13
. version ( '0.3.27' )
14
14
. usage ( '[options] <keywords>' )
15
15
. option ( '-b, --build [path/to/tutorial.md]' ,
16
- 'tutorial markdown file' , / ^ .+ \. m d $ / i)
16
+ 'tutorial markdown file' , / ^ .+ \. m d $ / i)
17
17
. option ( '-c, --create [name]' , 'tutorial name' )
18
18
. option ( '-p, --publish [version]' ,
19
- 'publish tutorial to npm with new version number' )
19
+ 'publish tutorial to npm with new version number' )
20
20
. option ( '-t, --tutorials' , 'list of tutorial packages' )
21
21
. option ( '-s, --search [query]' , 'search for tutorial package' )
22
22
. option ( '-r, --run' , 'run tutorial' )
@@ -55,6 +55,6 @@ switch (true) {
55
55
program . help ( ) ;
56
56
}
57
57
58
- // exit
58
+ // success! exit
59
59
process . stdout . write ( green ( ' ✓\n' ) ) ;
60
60
process . exit ( 0 ) ;
Original file line number Diff line number Diff line change 23
23
" src/build/parser/info.ts" ,
24
24
" src/build/parser/match.ts" ,
25
25
" src/build/parser/page.ts" ,
26
+ " src/build/parser/settings.ts" ,
26
27
" src/build/parser/task.ts" ,
27
28
" src/build/readme.ts" ,
28
29
" src/build/validators.ts" ,
You can’t perform that action at this time.
0 commit comments