This repository was archived by the owner on Mar 8, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +17
-8
lines changed Expand file tree Collapse file tree 3 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,6 @@ const expect = require("chai").expect;
33
44describe ( 'parse' , ( ) => {
55 it ( 'should return an function' , ( ) => {
6- expect ( parse . default ) . to . be . an ( 'function' )
6+ expect ( parse . parse ) . to . be . an ( 'function' )
77 } )
88} )
Original file line number Diff line number Diff line change 11import * as utils from './utils' ;
2- import parse from './parse' ;
3-
4- function defaultParse ( src ) {
5- return parse ( src ) ;
6- }
2+ import { parse , parseSource } from './parse' ;
73
84export {
9- defaultParse as parse ,
5+ parse ,
6+ parseSource ,
107 utils ,
118} ;
129
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import fs from 'fs';
22import * as utils from './utils' ;
33import stateDoc from './utils/stateDoc' ;
44
5- export default function parse ( file ) {
5+ export const parse = function ( file ) {
66 const source = fs . readFileSync ( file , { encoding : 'utf-8' } ) ;
77 if ( source === '' ) {
88 throw new Error ( 'The document is empty' ) ;
@@ -13,3 +13,15 @@ export default function parse(file) {
1313 const vueDoc = utils . getVueDoc ( stateDoc , component ) ;
1414 return vueDoc ;
1515}
16+
17+ export const parseSource = function ( source , path ) {
18+ if ( source === '' ) {
19+ throw new Error ( 'The document is empty' ) ;
20+ }
21+
22+ stateDoc . file = path ;
23+ stateDoc . saveComponent ( source , path ) ;
24+ const component = utils . getSandbox ( stateDoc . jscodeReqest , path ) . default ;
25+ const vueDoc = utils . getVueDoc ( stateDoc , component ) ;
26+ return vueDoc ;
27+ }
You can’t perform that action at this time.
0 commit comments