Skip to content

Commit 1b3f1dc

Browse files
committed
Update version to 0.1.0
This includes a generalized version of $apply
1 parent 18a6e5e commit 1b3f1dc

File tree

2 files changed

+38
-25
lines changed

2 files changed

+38
-25
lines changed

index.js

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,37 @@ function readGrammarFile(filename, significantScopeLast) {
2424
when we generate schema for SublimeText.
2525
*/
2626

27+
function _apply(obj) {
28+
if (obj instanceof Array) {
29+
for (var i = 0; i < obj.length; i++) {
30+
_apply(obj[i]);
31+
}
32+
}
33+
else if (obj && typeof obj == 'object') {
34+
if (obj.$apply && obj.$apply instanceof Array) {
35+
var specs = obj.$apply;
36+
for (var i = 0; i < specs.length; i++) {
37+
var spec = specs[i];
38+
39+
var inner = read(path.join(path.dirname(filename),
40+
spec.file),
41+
spec.vars);
42+
var inner_keys = Object.keys(inner);
43+
for (var j = 0; j < inner_keys.length; j++) {
44+
obj[inner_keys[j]] = inner[inner_keys[j]];
45+
}
46+
}
47+
delete obj['$apply'];
48+
}
49+
else {
50+
var keys = Object.keys(obj);
51+
for (var i = 0; i < keys.length; i++) {
52+
_apply(obj[keys[i]]);
53+
}
54+
}
55+
}
56+
}
57+
2758
function read(filename, vars) {
2859
var yamlSource = fs.readFileSync(filename, 'utf8'),
2960
hop = Object.prototype.hasOwnProperty;
@@ -41,25 +72,7 @@ function readGrammarFile(filename, significantScopeLast) {
4172
}
4273

4374
var schema = yaml.safeLoad(yamlSource);
44-
45-
if (schema.repository
46-
&& schema.repository.$apply
47-
&& schema.repository.$apply instanceof Array)
48-
{
49-
var specs = schema.repository.$apply;
50-
for (var i = 0; i < specs.length; i++) {
51-
var spec = specs[i];
52-
53-
var inner = read(path.join(path.dirname(filename),
54-
spec.file),
55-
spec.vars);
56-
57-
_.extend(schema.repository, inner.repository);
58-
}
59-
60-
delete schema.repository.$apply;
61-
}
62-
75+
_apply(schema);
6376
return schema;
6477
}
6578

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "syntaxdev",
3-
"version": "0.0.16",
3+
"version": "0.1.0",
44
"description": "Unit testing framework for TextMate/Sublime/Atom syntaxes.",
55
"main": "index.js",
66
"author": "Yury Selivanov <yury@magic.io>",
@@ -15,12 +15,12 @@
1515
"dependencies": {
1616
"first-mate": "^7.0.4",
1717
"js-yaml": "^3.4.2",
18-
"temp": "^0.8.3",
18+
"temp": "^0.9.0",
1919
"argparse": "^1.0.2",
20-
"diff": "^2.1.3",
21-
"chalk": "^1.1.1",
20+
"diff": "^4.0.1",
21+
"chalk": "^2.4.2",
2222
"underscore": "^1.8.3",
23-
"plist": "^1.1.0",
24-
"cson": "^3.0.2"
23+
"plist": "^3.0.1",
24+
"cson": "^5.1.0"
2525
}
2626
}

0 commit comments

Comments
 (0)