Skip to content

Commit 7175adb

Browse files
committed
compile content with TS compiler
1 parent 44a38ac commit 7175adb

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5-
## [0.9.2] - 2016-08-01
5+
## [0.9.3] - 2016-08-01
66
- add "exists" global file path checker
77
- upgrade to [email protected]
88
- set "node_modules" to user project directory
9+
- compile JS code to ES5 using the TypeScript compiler
10+
- allows for both ES6 & TypeScript input
911

1012
## [0.8.0] - 2016-06-28
1113
- load with object

lib/write-test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ var fs_1 = require('fs');
33
var process_console_log_1 = require('process-console-log');
44
var exists_1 = require('./exists');
55
var constants_1 = require('./constants');
6+
var ts = require('typescript');
67
function writeTest(config, testString) {
78
return new Promise(function (resolve, reject) {
8-
var output = process_console_log_1.logger + exists_1.default(config.dir) + testString;
9+
var output = process_console_log_1.logger + exists_1.default(config.dir) + ts.transpile(testString, {
10+
module: ts.ModuleKind.CommonJS
11+
});
912
fs_1.writeFile(constants_1.testPath, output, function (err) {
1013
if (err) {
1114
reject(err);

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mocha-coderoad",
3-
"version": "0.9.2",
3+
"version": "0.9.3",
44
"description": "mocha test runner & reporter for atom-coderoad",
55
"main": "lib/index.js",
66
"scripts": {
@@ -28,7 +28,8 @@
2828
"dependencies": {
2929
"mocha": "^3.0.0",
3030
"node-file-exists": "^1.1.0",
31-
"process-console-log": "^0.2.2"
31+
"process-console-log": "^0.2.2",
32+
"typescript": "^1.8.10"
3233
},
3334
"devDependencies": {
3435
"chai": "^3.5.0",

src/write-test.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ import {writeFile} from 'fs';
22
import {logger} from 'process-console-log';
33
import exists from './exists';
44
import {testPath} from './constants';
5+
import * as ts from 'typescript';
56

67
export default function writeTest(config, testString: string) {
78
return new Promise((resolve, reject) => {
8-
// append logger
9-
const output = logger + exists(config.dir) + testString;
9+
// append logger, compile using ts compiler
10+
const output = logger + exists(config.dir) + ts.transpile(testString, {
11+
module: ts.ModuleKind.CommonJS
12+
});
1013
// write test file
1114
writeFile(testPath, output, (err) => {
1215
if (err) { reject(err); }

0 commit comments

Comments
 (0)