Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a script for converting to textmate format
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
let nlist = require("nextstep-plist") | ||
let filepath = process.argv[2] | ||
let path = require("path") | ||
|
||
if (!filepath || !filepath.endsWith(".json")) { | ||
console.log("please provide a path to a json file mate") | ||
process.exit(1) | ||
} | ||
|
||
let syntax = require(path.resolve(__dirname, filepath)) | ||
|
||
let flurp = r => | ||
r.replace(/# .*/g, '').replace(/\s/g, '') | ||
|
||
let grith = patterns => { | ||
for (let pattern of patterns) { | ||
for (let key in pattern) { | ||
if (key == "begin" || key == "match") { | ||
pattern[key] = flurp(pattern[key]) | ||
} | ||
} | ||
} | ||
} | ||
|
||
grith(syntax.patterns) | ||
|
||
for (let repo in syntax.repository) { | ||
grith(syntax.repository[repo].patterns) | ||
} | ||
|
||
console.log(nlist.stringify(syntax)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters