Skip to content
This repository has been archived by the owner on Jun 27, 2018. It is now read-only.

Commit

Permalink
Merge pull request #84 from teppeis/types
Browse files Browse the repository at this point in the history
fix: support `types` option with TypeScript 2.4.1
  • Loading branch information
teppeis authored Jul 2, 2017
2 parents 1642a86 + 6e97d29 commit c3ff186
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 18 deletions.
68 changes: 68 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
workflows:
version: 2
node-multi-build:
jobs:
- node-v4
- node-v6
- node-v8

version: 2
jobs:
node-base: &node-base
docker:
- image: node
environment:
working_directory: ~/working_directory
steps:
- run:
name: Versions
command: |
yarn versions
echo "npm: $(npm --version)"
- checkout
- restore_cache:
keys:
- v{{ .Environment.CIRCLE_CACHE_VERSION }}-npm-lock-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package-lock.json" }}
- v{{ .Environment.CIRCLE_CACHE_VERSION }}-npm-lock-master-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package-lock.json" }}
- v{{ .Environment.CIRCLE_CACHE_VERSION }}-npm-cache-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}
- v{{ .Environment.CIRCLE_CACHE_VERSION }}-npm-cache-master-{{ .Environment.CIRCLE_JOB }}
- run:
name: Install dependencies
command: npm install
- run:
name: Test with TypeScript 2.2
command: |
npm install --no-save [email protected]
npm test
- run:
name: Test with TypeScript 2.3
command: |
npm install --no-save [email protected]
npm test
- run:
name: Test with TypeScript 2.4
command: |
npm install --no-save [email protected]
npm test
- save_cache:
key: v{{ .Environment.CIRCLE_CACHE_VERSION }}-npm-lock-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package-lock.json" }}
paths:
- node_modules
- save_cache:
key: v{{ .Environment.CIRCLE_CACHE_VERSION }}-npm-cache-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package-lock.json" }}
paths:
- /usr/local/share/.cache/yarn
- ~/.npm/_cacache

node-v4:
<<: *node-base
docker:
- image: node:4
node-v6:
<<: *node-base
docker:
- image: node:6
node-v8:
<<: *node-base
docker:
- image: node:8
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Simple API to compile TypeScript code string to JavaScript. That's all!
[![npm version][npm-image]][npm-url]
[![npm downloads][npm-downloads-image]][npm-url]
![Node.js Version Support][node-version]
[![build status][travis-image]][travis-url]
[![build status][circleci-image]][circleci-url]
[![windows build status][appveyor-image]][appveyor-url]
[![dependency status][deps-image]][deps-url]
![License][license]
Expand Down Expand Up @@ -156,3 +156,5 @@ MIT License: Teppei Sato &lt;[email protected]&gt;
[license]: https://img.shields.io/npm/l/typescript-simple.svg
[appveyor-image]: https://ci.appveyor.com/api/projects/status/22nwyfaf5p0yw54j/branch/master?svg=true
[appveyor-url]: https://ci.appveyor.com/project/teppeis/typescript-simple/branch/master
[circleci-image]: https://circleci.com/gh/teppeis/typescript-simple.svg?style=svg
[circleci-url]: https://circleci.com/gh/teppeis/typescript-simple
5 changes: 5 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ test_script:
- node --version
- npm --version
# run tests
- npm install --no-save [email protected]
- npm test
- npm install --no-save [email protected]
- npm test
- npm install --no-save [email protected]
- npm test

# Don't actually build.
Expand Down
17 changes: 16 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,24 @@ namespace tss {
getNewLine: () => os.EOL,
log: (message: string) => console.log(message),
trace: (message: string) => console.debug(message),
error: (message: string) => console.error(message)
error: (message: string) => console.error(message),
readFile: readFile,
fileExists: fileExists
};

function readFile(filename: string, encoding?: string): string {
try {
const content = fs.readFileSync(filename, encoding || 'utf8');
return content;
} catch (e) {
return '';
}
}

function fileExists(filename: string): boolean {
return readFile(filename) !== '';
}

return ts.createLanguageService(serviceHost, ts.createDocumentRegistry())
}

Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"typescript": "^2.2.1"
},
"devDependencies": {
"@types/node": "^7.0.31",
"@types/node": "^8.0.7",
"mocha": "^3.1.2"
},
"homepage": "https://github.com/teppeis/typescript-simple",
Expand Down
5 changes: 5 additions & 0 deletions test/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"env": {
"mocha": true
}
}
7 changes: 7 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,11 @@ describe('typescript-simple', function() {
assert.equal(tss.compile(src, path.join(__dirname, 'module.ts')), expected);
assert.equal(tss.compile(src, path.join('test', 'module.ts')), expected);
});

it('compiles correct source with `types`', function() {
var tss = new TypeScriptSimple({types: ['node']});
var src = "var x: number = 1;";
var expected = 'var x = 1;' + eol;
assert.equal(tss.compile(src), expected);
});
});

0 comments on commit c3ff186

Please sign in to comment.