修改构建方式,升级peg为0.10.0
This commit is contained in:
		
							
								
								
									
										16062
									
								
								core/astParser.js
									
									
									
									
									
								
							
							
						
						
									
										16062
									
								
								core/astParser.js
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										2069
									
								
								core/comment.js
									
									
									
									
									
								
							
							
						
						
									
										2069
									
								
								core/comment.js
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										6
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@ -11,9 +11,9 @@
 | 
			
		||||
      "dev": true
 | 
			
		||||
    },
 | 
			
		||||
    "pegjs": {
 | 
			
		||||
      "version": "0.7.0",
 | 
			
		||||
      "resolved": "http://registry.npm.taobao.org/pegjs/download/pegjs-0.7.0.tgz",
 | 
			
		||||
      "integrity": "sha1-qqH4JPnnGX7ETiKlevUi9wDdaJ4=",
 | 
			
		||||
      "version": "0.10.0",
 | 
			
		||||
      "resolved": "http://registry.npm.taobao.org/pegjs/download/pegjs-0.10.0.tgz",
 | 
			
		||||
      "integrity": "sha1-z4uvrm7d/0tafvsYUmnqr0YQ3b0=",
 | 
			
		||||
      "dev": true
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -4,14 +4,14 @@
 | 
			
		||||
  "description": "sql parser",
 | 
			
		||||
  "main": "index.js",
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "build:parse": "pegjs   peg/nquery.pegjs core/astParser.js",
 | 
			
		||||
    "build:filter":"pegjs   peg/comment.pegjs core/comment.js"
 | 
			
		||||
    "build:parse": "pegjs  -o core/astParser.js peg/nquery.pegjs ",
 | 
			
		||||
    "build:filter": "pegjs -o core/comment.js peg/comment.pegjs "
 | 
			
		||||
  },
 | 
			
		||||
  "author": "xiaokang",
 | 
			
		||||
  "license": "ISC",
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "node-query": "^0.3.3",
 | 
			
		||||
    "pegjs": "^0.7.0"
 | 
			
		||||
    "pegjs": "^0.10.0"
 | 
			
		||||
  },
 | 
			
		||||
  "dependencies": {}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										20
									
								
								peg/build.js
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								peg/build.js
									
									
									
									
									
								
							@ -2,6 +2,8 @@ const pegjs=require("pegjs");
 | 
			
		||||
const path=require("path");
 | 
			
		||||
const fs=require("fs");
 | 
			
		||||
 | 
			
		||||
const ENCODING="utf8"
 | 
			
		||||
 | 
			
		||||
const files=[{
 | 
			
		||||
    source:path.resolve(process.cwd(),"./peg/comment.pegjs") ,
 | 
			
		||||
    target:path.resolve(process.cwd(),"./core/comment.js") ,
 | 
			
		||||
@ -10,5 +12,19 @@ const files=[{
 | 
			
		||||
    target:path.resolve(process.cwd(),"./core/astParser.js") ,
 | 
			
		||||
}];
 | 
			
		||||
 | 
			
		||||
const file=fs.readFileSync(files[0].source,{encoding:"utf8"})
 | 
			
		||||
pegjs.buildParser(file);
 | 
			
		||||
 | 
			
		||||
function writeIn(file,data){
 | 
			
		||||
    fs.writeFileSync(file,data,{encoding:ENCODING})
 | 
			
		||||
}
 | 
			
		||||
function build(content){
 | 
			
		||||
    return pegjs.generate(content,{
 | 
			
		||||
        output:"source",
 | 
			
		||||
        format:"umd"
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
files.forEach(
 | 
			
		||||
    (file)=>{
 | 
			
		||||
        let fileContent=fs.readFileSync(file.source,{encoding:ENCODING})
 | 
			
		||||
        writeIn(file.target,build(fileContent))
 | 
			
		||||
    }
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@ -278,7 +278,7 @@ table_name
 | 
			
		||||
        db : '',
 | 
			
		||||
        table : dt
 | 
			
		||||
      }
 | 
			
		||||
      if (tail != '') {
 | 
			
		||||
      if (tail) {
 | 
			
		||||
        obj.db = dt;
 | 
			
		||||
        obj.table = tail[3];
 | 
			
		||||
      } 
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user