@travetto/compiler
Advanced tools
Comparing version 0.0.35 to 0.0.36
@@ -22,3 +22,3 @@ { | ||
"scripts": {}, | ||
"version": "0.0.35" | ||
"version": "0.0.36" | ||
} |
import * as ts from 'typescript'; | ||
import { EventEmitter } from 'events'; | ||
import { AppInfo } from '@travetto/base'; | ||
import { AppInfo, AppEnv } from '@travetto/base'; | ||
import { TransformerManager } from './transformers'; | ||
@@ -26,3 +26,3 @@ import { CompilerUtil } from './util'; | ||
constructor(public cwd: string = process.cwd()) { | ||
constructor(public cwd: string = AppEnv.cwd) { | ||
@@ -29,0 +29,0 @@ const exclude = [/\.d\.ts$/g]; // Definition files |
@@ -7,4 +7,2 @@ import * as fs from 'fs'; | ||
const { cwd, cache } = AppEnv; | ||
const stringHash = require('string-hash'); | ||
@@ -17,14 +15,6 @@ | ||
constructor(private config: { cache?: boolean, cacheDir?: string } = {}) { | ||
constructor(private config: { cache?: boolean } = {}) { | ||
Object.assign(config, { ... { cache: true }, config }); | ||
try { | ||
fs.mkdirSync(this.config.cacheDir!); | ||
} catch (e) { } | ||
} | ||
private resolveCacheName(fileName: string) { | ||
return `${cache.dir}/${fileName.replace(cwd, '').replace(/[\/\\]/g, cache.sep).replace(/.ts$/, '@ts')}`; | ||
} | ||
registerSourceMaps() { | ||
@@ -112,3 +102,3 @@ sourcemap.install({ | ||
if (this.config.cache) { | ||
fs.writeFileSync(this.resolveCacheName(name), content); | ||
fs.writeFileSync(AppEnv.cache.toEntryName(name), content); | ||
} | ||
@@ -124,11 +114,11 @@ } | ||
hasCached(file: string) { | ||
return this.config.cache && fs.existsSync(this.resolveCacheName(file)); | ||
return this.config.cache && fs.existsSync(AppEnv.cache.toEntryName(file)); | ||
} | ||
getCached(file: string) { | ||
return fs.readFileSync(this.resolveCacheName(file)).toString(); | ||
return fs.readFileSync(AppEnv.cache.toEntryName(file)).toString(); | ||
} | ||
deleteCached(file: string) { | ||
fs.unlinkSync(this.resolveCacheName(file)); | ||
fs.unlinkSync(AppEnv.cache.toEntryName(file)); | ||
} | ||
@@ -135,0 +125,0 @@ |
26545
723