11"use strict" ;
22var fs = require ( 'fs' ) ;
3- var process = require ( 'process' ) ;
4- var chalk = require ( 'chalk' ) ;
53var Match = require ( './matchers' ) ;
6- var validators_1 = require ( './validators' ) ;
4+ var validate = require ( './validators' ) ;
75var actions_1 = require ( './actions' ) ;
86var cleanup_1 = require ( './cleanup' ) ;
97function build ( lines ) {
@@ -123,16 +121,17 @@ function task(result, lines, index) {
123121 inCodeBlock = ! inCodeBlock ;
124122 }
125123 if ( ! inCodeBlock ) {
126- if ( ! ! Match . isAction ( line ) ) {
127- var isActionArray = Match . isArray ( cleanup_1 . trimQuotes ( line ) ) ;
124+ var isAction = Match . isAction ( line ) ;
125+ if ( ! ! isAction ) {
126+ var isActionArray = Match . isArray ( cleanup_1 . trimQuotes ( isAction [ 2 ] ) ) ;
128127 if ( ! ! isActionArray ) {
129- arrayOfActions = JSON . parse ( isActionArray ) ;
130- arrayOfActions . forEach ( function ( line ) {
131- result = actions_1 . default ( result , line , index ) ;
128+ var arrayOfActions = JSON . parse ( isActionArray ) ;
129+ arrayOfActions . forEach ( function ( action ) {
130+ result = actions_1 . addToTasks ( result , "@action(" + action + ")" , index ) ;
132131 } ) ;
133132 }
134133 else {
135- result = actions_1 . default ( result , line , index ) ;
134+ result = actions_1 . addToTasks ( result , line , index ) ;
136135 }
137136 }
138137 else if ( ! ! Match . task ( line ) ) {
@@ -156,13 +155,10 @@ function task(result, lines, index) {
156155}
157156module . exports = function ( filePath , output ) {
158157 if ( output === void 0 ) { output = './coderoad.json' ; }
159- if ( ! filePath ) {
160- console . log ( chalk . red ( "\n Pass in a path to your .md file\n For example: coderoad build ./src/tutorial.md\n " ) ) ;
161- process . exit ( 1 ) ;
162- }
158+ validate . filePath ( filePath ) ;
163159 var lines = fs . readFileSync ( filePath , 'utf8' ) . split ( '\n' ) ;
164160 var result = cleanup_1 . cleanup ( build ( lines ) ) ;
165- if ( validators_1 . default ( result ) ) {
161+ if ( validate . result ( result ) ) {
166162 fs . writeFileSync ( output , result , 'utf8' ) ;
167163 }
168164} ;
0 commit comments