1
- import * as yamlParser from 'js-yaml'
2
- import * as path from 'path'
3
- import * as fs from 'fs'
4
- import * as util from 'util'
1
+ import { load } from 'js-yaml'
2
+ import { join } from 'path'
3
+ import { writeFile , readFile } from 'fs'
4
+ import { promisify } from 'util'
5
5
import { parse } from './utils/parse'
6
6
import { getArg } from './utils/args'
7
7
import { getCommits , CommitLogObject } from './utils/commits'
@@ -11,8 +11,8 @@ import { validateSchema } from './utils/validateSchema'
11
11
import { validateMarkdown } from './utils/validateMarkdown'
12
12
import * as T from '../typings/tutorial'
13
13
14
- const write = util . promisify ( fs . writeFile )
15
- const read = util . promisify ( fs . readFile )
14
+ const write = promisify ( writeFile )
15
+ const read = promisify ( readFile )
16
16
17
17
export type BuildConfigOptions = {
18
18
text :string // text document from markdown
@@ -60,15 +60,15 @@ async function build (args: string[]) {
60
60
}
61
61
62
62
// path to run build from
63
- const localPath = path . join ( process . cwd ( ) , options . dir )
63
+ const localPath = join ( process . cwd ( ) , options . dir )
64
64
65
65
// load markdown and files
66
66
let _markdown :string
67
67
let _yaml :string
68
68
try {
69
69
; [ _markdown , _yaml ] = await Promise . all ( [
70
- read ( path . join ( localPath , options . markdown ) , 'utf8' ) ,
71
- read ( path . join ( localPath , options . yaml ) , 'utf8' )
70
+ read ( join ( localPath , options . markdown ) , 'utf8' ) ,
71
+ read ( join ( localPath , options . yaml ) , 'utf8' )
72
72
] )
73
73
} catch ( e ) {
74
74
console . error ( 'Error reading file:' )
@@ -91,7 +91,7 @@ async function build (args: string[]) {
91
91
// parse yaml skeleton config
92
92
let skeleton
93
93
try {
94
- skeleton = yamlParser . load ( _yaml ) as T . TutorialSkeleton
94
+ skeleton = load ( _yaml ) as T . TutorialSkeleton
95
95
if ( ! skeleton || ! Object . keys ( skeleton ) . length ) {
96
96
throw new Error ( `Skeleton at "${ options . yaml } " is invalid` )
97
97
}