Skip to content

Commit 90b42d3

Browse files
committed
set script in instance
1 parent 141c75a commit 90b42d3

File tree

5 files changed

+19
-8
lines changed

5 files changed

+19
-8
lines changed

index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import Imports from './modules/imports'
55

66
class VueScriptParser {
77
constructor(vueScript = '') {
8+
9+
//set original script
10+
this.script = vueScript
11+
812
//load imports
913
let importsProcessor = new Imports(vueScript)
1014
this.imports = importsProcessor.imports
@@ -20,6 +24,13 @@ class VueScriptParser {
2024
//load methods
2125
let methodsProcessor = new Methods(vueScript)
2226
this.methods = methodsProcessor.methods
27+
28+
}
29+
addVariable () {
30+
31+
}
32+
removeVariable () {
33+
2334
}
2435
}
2536

modules/data.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
import Vue from 'vue'
33
class Data {
44
constructor(vueScript = '') {
5-
this.data = this.setData(vueScript)
5+
this.data = this.dataReader(vueScript)
66
}
77

8-
setData (vueScript = '') {
8+
dataReader (vueScript = '') {
99
let dataRegx = /data\s*\(\s*\)\s*\{\s*return\s*{([^]*)}/g
1010
let processedData = this.extractAndUpdateData(vueScript, dataRegx)
1111

modules/imports.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
class Imports {
22
constructor(vueScript = '') {
3-
this.imports = this.setImports(vueScript) || []
3+
this.imports = this.importsReader(vueScript) || []
44
}
5-
setImports (vueScript) {
5+
importsReader (vueScript) {
66
return vueScript.match(/import .*/g)
77
}
88

modules/methods.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { scriptSectionProcessing } from './common'
22

33
class Methods {
44
constructor(vueScript = '') {
5-
this.methods = this.setMethod(vueScript)
5+
this.methods = this.methodsReader(vueScript)
66
}
7-
setMethod (vueScript = '') {
7+
methodsReader (vueScript = '') {
88
let regx = /methods\s*:\s*{([^]*)}/g
99
let matchMethods = vueScript.match(regx)
1010
if (!matchMethods) {

modules/mounted.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { scriptSectionProcessing } from './common'
22
class Mounted {
33
constructor(vueScript) {
44
let regx = /mounted\s*\(\s*\)\s*{([^]*)}/g
5-
this.mounted = this.extractAndUpdateMounted(regx, vueScript)
5+
this.mounted = this.mountedReader(regx, vueScript)
66
}
7-
extractAndUpdateMounted (regx, vueScript) {
7+
mountedReader (regx, vueScript) {
88
let newScript = ''
99
let matchMounted = vueScript.match(regx)
1010
if (!matchMounted) {

0 commit comments

Comments
 (0)