Skip to content

Commit 8b528dc

Browse files
committed
Combine builds and tests generation, add travis ci
1 parent 99cf295 commit 8b528dc

File tree

7 files changed

+86
-61
lines changed

7 files changed

+86
-61
lines changed

.gitignore

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
build/node_modules
2-
build/typings/
1+
node_modules
32
build/*.js
4-
tests/generated/*
5-
tests/node_modules
6-
tests/typings/
7-
tests/*.js
3+
tests/*.js
4+
tests/generated/*

.travis.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
language: node_js
2+
3+
node_js:
4+
- 'stable'
5+
- '8'
6+
7+
sudo: false
8+
9+
env:
10+
- workerCount=2
11+
12+
matrix:
13+
fast_finish: true
14+
15+
branches:
16+
only:
17+
- master
18+
19+
install:
20+
- npm install
21+
22+
cache:
23+
directories:
24+
- node_modules
25+
26+
git:
27+
depth: 1

appveyor.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ install:
77
- ps: Install-Product node $env:nodejs_version
88
- node --version
99
- npm --version
10-
- cd build
11-
- npm install
12-
- cd ../tests
1310
- npm install
1411
- npm test
1512

build/build.ts

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@ import path = require('path');
33
import yaml = require('js-yaml');
44
import plist = require('plist');
55

6+
enum Language {
7+
TypeScript = "TypeScript",
8+
TypeScriptReact = "TypeScriptReact"
9+
}
10+
11+
enum Extension {
12+
TmLanguage = "tmLanguage",
13+
TmTheme = "tmTheme",
14+
YamlTmLangauge = "YAML-tmLanguage",
15+
YamlTmTheme = "YAML-tmTheme"
16+
}
17+
18+
function file(language: Language, extension: Extension) {
19+
return path.join(__dirname, '..', `${language}.${extension}`);
20+
}
21+
622
function writePlistFile(grammar: any, fileName: string) {
723
const text = plist.build(grammar);
824
fs.writeFileSync(fileName, text);
@@ -40,7 +56,7 @@ function transformGrammarRepository(grammar: any, propertyNames: string[], trans
4056
}
4157

4258
function changeTsToTsxGrammar(grammar: any, variables: any) {
43-
const tsxUpdates = updateGrammarVariables(readYaml("../TypeScriptReact.YAML-tmLanguage"), variables);
59+
const tsxUpdates = updateGrammarVariables(readYaml(file(Language.TypeScriptReact, Extension.YamlTmLangauge)), variables);
4460

4561
// Update name, file types, scope name and uuid
4662
for (let key in tsxUpdates) {
@@ -96,21 +112,21 @@ function updateGrammarVariables(grammar: any, variables: any) {
96112
}
97113

98114
function buildGrammar() {
99-
const tsGrammarBeforeTransformation = readYaml("../TypeScript.YAML-tmLanguage");
115+
const tsGrammarBeforeTransformation = readYaml(file(Language.TypeScript, Extension.YamlTmLangauge));
100116
const variables = tsGrammarBeforeTransformation.variables;
101117

102118
const tsGrammar = updateGrammarVariables(tsGrammarBeforeTransformation, variables);
103119

104120
// Write TypeScript.tmLanguage
105-
writePlistFile(tsGrammar, "../TypeScript.tmLanguage");
121+
writePlistFile(tsGrammar, file(Language.TypeScript, Extension.TmLanguage));
106122

107123
// Write TypeScriptReact.tmLangauge
108124
const tsxGrammar = changeTsToTsxGrammar(tsGrammar, variables);
109-
writePlistFile(tsxGrammar, "../TypeScriptReact.tmLanguage");
125+
writePlistFile(tsxGrammar, file(Language.TypeScriptReact, Extension.TmLanguage));
110126
}
111127

112128
function changeTsToTsxTheme(theme: any) {
113-
const tsxUpdates = readYaml("../TypeScriptReact.YAML-tmTheme");
129+
const tsxUpdates = readYaml(file(Language.TypeScriptReact, Extension.YamlTmTheme));
114130

115131
// Update name, uuid
116132
for (let key in tsxUpdates) {
@@ -132,14 +148,14 @@ function changeTsToTsxTheme(theme: any) {
132148
}
133149

134150
function buildTheme() {
135-
const tsTheme = readYaml("../TypeScript.YAML-tmTheme");
151+
const tsTheme = readYaml(file(Language.TypeScript, Extension.YamlTmTheme));
136152

137153
// Write TypeScript.tmTheme
138-
writePlistFile(tsTheme, "../TypeScript.tmTheme");
154+
writePlistFile(tsTheme, file(Language.TypeScript, Extension.TmTheme));
139155

140156
// Write TypeScriptReact.thTheme
141157
const tsxTheme = changeTsToTsxTheme(tsTheme);
142-
writePlistFile(tsxTheme, "../TypeScriptReact.tmTheme");
158+
writePlistFile(tsxTheme, file(Language.TypeScriptReact, Extension.TmTheme));
143159
}
144160

145161
buildGrammar();

build/package.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

package.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "typescript-tmlanguage",
3+
"version": "1.0.0",
4+
"private": true,
5+
"description": "TextMate grammar files for TypeScript for VS Code, Sublime Text, and Atom",
6+
"main": "build/build.js",
7+
"scripts": {
8+
"build": "npm run build:grammar && npm run build:tests",
9+
"build:grammar": "tsc -p build && node build/build.js",
10+
"build:tests": "tsc -p tests",
11+
"pretest": "npm run build",
12+
"test": "mocha --full-trace tests/test.js",
13+
"diff": "cross-env-shell $DIFF tests/baselines tests/generated",
14+
"accept": "cpx tests/generated/* tests/baselines"
15+
},
16+
"dependencies": {
17+
"chai": "latest",
18+
"js-yaml": "latest",
19+
"mocha": "latest",
20+
"plist": "latest",
21+
"typescript": "latest",
22+
"vscode-textmate": "latest",
23+
"@types/chai": "latest",
24+
"@types/js-yaml": "latest",
25+
"@types/mocha": "latest",
26+
"@types/node": "latest"
27+
},
28+
"devDependencies": {
29+
"cpx": "^1.5.0",
30+
"cross-env": "^5.1.1"
31+
}
32+
}

tests/package.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)