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;
3
3
4
4
describe ( 'parse' , ( ) => {
5
5
it ( 'should return an function' , ( ) => {
6
- expect ( parse . default ) . to . be . an ( 'function' )
6
+ expect ( parse . parse ) . to . be . an ( 'function' )
7
7
} )
8
8
} )
Original file line number Diff line number Diff line change 1
1
import * 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' ;
7
3
8
4
export {
9
- defaultParse as parse ,
5
+ parse ,
6
+ parseSource ,
10
7
utils ,
11
8
} ;
12
9
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import fs from 'fs';
2
2
import * as utils from './utils' ;
3
3
import stateDoc from './utils/stateDoc' ;
4
4
5
- export default function parse ( file ) {
5
+ export const parse = function ( file ) {
6
6
const source = fs . readFileSync ( file , { encoding : 'utf-8' } ) ;
7
7
if ( source === '' ) {
8
8
throw new Error ( 'The document is empty' ) ;
@@ -13,3 +13,15 @@ export default function parse(file) {
13
13
const vueDoc = utils . getVueDoc ( stateDoc , component ) ;
14
14
return vueDoc ;
15
15
}
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