Skip to content

Commit

Permalink
Combine builds and tests generation, add travis ci
Browse files Browse the repository at this point in the history
  • Loading branch information
sheetalkamat committed Jan 25, 2018
1 parent 99cf295 commit 8b528dc
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 61 deletions.
9 changes: 3 additions & 6 deletions .gitignore
@@ -1,7 +1,4 @@
build/node_modules
build/typings/
node_modules
build/*.js
tests/generated/*
tests/node_modules
tests/typings/
tests/*.js
tests/*.js
tests/generated/*
27 changes: 27 additions & 0 deletions .travis.yml
@@ -0,0 +1,27 @@
language: node_js

node_js:
- 'stable'
- '8'

sudo: false

env:
- workerCount=2

matrix:
fast_finish: true

branches:
only:
- master

install:
- npm install

cache:
directories:
- node_modules

git:
depth: 1
3 changes: 0 additions & 3 deletions appveyor.yml
Expand Up @@ -7,9 +7,6 @@ install:
- ps: Install-Product node $env:nodejs_version
- node --version
- npm --version
- cd build
- npm install
- cd ../tests
- npm install
- npm test

Expand Down
32 changes: 24 additions & 8 deletions build/build.ts
Expand Up @@ -3,6 +3,22 @@ import path = require('path');
import yaml = require('js-yaml');
import plist = require('plist');

enum Language {
TypeScript = "TypeScript",
TypeScriptReact = "TypeScriptReact"
}

enum Extension {
TmLanguage = "tmLanguage",
TmTheme = "tmTheme",
YamlTmLangauge = "YAML-tmLanguage",
YamlTmTheme = "YAML-tmTheme"
}

function file(language: Language, extension: Extension) {
return path.join(__dirname, '..', `${language}.${extension}`);
}

function writePlistFile(grammar: any, fileName: string) {
const text = plist.build(grammar);
fs.writeFileSync(fileName, text);
Expand Down Expand Up @@ -40,7 +56,7 @@ function transformGrammarRepository(grammar: any, propertyNames: string[], trans
}

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

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

function buildGrammar() {
const tsGrammarBeforeTransformation = readYaml("../TypeScript.YAML-tmLanguage");
const tsGrammarBeforeTransformation = readYaml(file(Language.TypeScript, Extension.YamlTmLangauge));
const variables = tsGrammarBeforeTransformation.variables;

const tsGrammar = updateGrammarVariables(tsGrammarBeforeTransformation, variables);

// Write TypeScript.tmLanguage
writePlistFile(tsGrammar, "../TypeScript.tmLanguage");
writePlistFile(tsGrammar, file(Language.TypeScript, Extension.TmLanguage));

// Write TypeScriptReact.tmLangauge
const tsxGrammar = changeTsToTsxGrammar(tsGrammar, variables);
writePlistFile(tsxGrammar, "../TypeScriptReact.tmLanguage");
writePlistFile(tsxGrammar, file(Language.TypeScriptReact, Extension.TmLanguage));
}

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

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

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

// Write TypeScript.tmTheme
writePlistFile(tsTheme, "../TypeScript.tmTheme");
writePlistFile(tsTheme, file(Language.TypeScript, Extension.TmTheme));

// Write TypeScriptReact.thTheme
const tsxTheme = changeTsToTsxTheme(tsTheme);
writePlistFile(tsxTheme, "../TypeScriptReact.tmTheme");
writePlistFile(tsxTheme, file(Language.TypeScriptReact, Extension.TmTheme));
}

buildGrammar();
Expand Down
18 changes: 0 additions & 18 deletions build/package.json

This file was deleted.

32 changes: 32 additions & 0 deletions package.json
@@ -0,0 +1,32 @@
{
"name": "typescript-tmlanguage",
"version": "1.0.0",
"private": true,
"description": "TextMate grammar files for TypeScript for VS Code, Sublime Text, and Atom",
"main": "build/build.js",
"scripts": {
"build": "npm run build:grammar && npm run build:tests",
"build:grammar": "tsc -p build && node build/build.js",
"build:tests": "tsc -p tests",
"pretest": "npm run build",
"test": "mocha --full-trace tests/test.js",
"diff": "cross-env-shell $DIFF tests/baselines tests/generated",
"accept": "cpx tests/generated/* tests/baselines"
},
"dependencies": {
"chai": "latest",
"js-yaml": "latest",
"mocha": "latest",
"plist": "latest",
"typescript": "latest",
"vscode-textmate": "latest",
"@types/chai": "latest",
"@types/js-yaml": "latest",
"@types/mocha": "latest",
"@types/node": "latest"
},
"devDependencies": {
"cpx": "^1.5.0",
"cross-env": "^5.1.1"
}
}
26 changes: 0 additions & 26 deletions tests/package.json

This file was deleted.

0 comments on commit 8b528dc

Please sign in to comment.