ts-node-dev
Advanced tools
Comparing version
@@ -20,4 +20,4 @@ var fs = require('fs') | ||
var timeout = false | ||
while (compiled === undefined || timeout) { | ||
if (fs.existsSync(compiledPath)) { | ||
while (compiled === undefined || timeout) { | ||
if (fs.existsSync(compiledPath + '.done')) { | ||
compiled = fs.readFileSync(compiledPath, 'utf-8') | ||
@@ -61,3 +61,2 @@ } | ||
if (fs.existsSync(tsFileName)) { | ||
// console.log('prefere ts file', tsFileName) | ||
tsCode = fs.readFileSync(tsFileName, 'utf-8') | ||
@@ -64,0 +63,0 @@ } |
@@ -106,2 +106,6 @@ var register = require('ts-node').register | ||
var compiledPath = params.compiledPath | ||
function writeCompiled(code) { | ||
fs.writeFileSync(compiledPath, code) | ||
fs.writeFileSync(compiledPath + '.done', '') | ||
} | ||
if (fs.existsSync(compiledPath)) { | ||
@@ -111,5 +115,3 @@ return | ||
var m = { | ||
_compile: function (code) { | ||
fs.writeFileSync(compiledPath, code, 'utf-8') | ||
} | ||
_compile: writeCompiled | ||
} | ||
@@ -122,3 +124,3 @@ tsHandler(m, fileName) | ||
code = 'throw new Error("Unable to compile TypeScript");' | ||
fs.writeFileSync(compiledPath, code, 'utf-8') | ||
writeCompiled(code) | ||
} | ||
@@ -125,0 +127,0 @@ } |
@@ -5,5 +5,9 @@ var crypto = require('crypto') | ||
module.exports = (code, fileName, compiledDir) => { | ||
var hashed = crypto.createHash('sha256') | ||
.update(fileName + code, 'utf8').digest('hex') + '.js' | ||
return join(compiledDir, hashed) | ||
var hash = crypto.createHash('sha256') | ||
.update(fileName + code, 'utf8').digest('hex') | ||
var hashed = | ||
fileName.replace(/[^\w]/g, '_') + | ||
'_' + hash + | ||
'.js' | ||
return join(compiledDir, hashed ) | ||
} |
{ | ||
"name": "ts-node-dev", | ||
"version": "1.0.0-pre.2", | ||
"version": "1.0.0-pre.3", | ||
"description": "Compiles your TS app and restarts when files are modified.", | ||
@@ -36,3 +36,3 @@ "keywords": [ | ||
"test1": "tap test/*.js", | ||
"ts-test": "rimraf .ts-node && node ./bin/ts-node-dev --respawn --prefer-ts test-script" | ||
"ts-test": "node ./bin/ts-node-dev -r ./test/ts/add-require.js --respawn --prefer-ts --cache-directory .ts-node test/ts/test-script test-arg --fd" | ||
}, | ||
@@ -50,2 +50,3 @@ "dependencies": { | ||
"devDependencies": { | ||
"@types/node": "^8.0.4", | ||
"coffee-script": "^1.8.0", | ||
@@ -52,0 +53,0 @@ "eslint": "^2.0.0", |
Sorry, the diff of this file is not supported yet
573
0.88%26954
-0.49%8
14.29%