Skip to content
This repository was archived by the owner on Mar 8, 2019. It is now read-only.

Commit 341cbd0

Browse files
committed
Merge branch 'Radiergummi-master'
2 parents 9d207e9 + 1198d02 commit 341cbd0

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

src/__tests__/parse.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ const expect = require("chai").expect;
33

44
describe('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
})

src/main.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
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';
73

84
export {
9-
defaultParse as parse,
5+
parse,
6+
parseSource,
107
utils,
118
};
129

src/parse.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from 'fs';
22
import * as utils from './utils';
33
import 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+
}

0 commit comments

Comments
 (0)