diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index a725411..164c70a 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -1,7 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const express = require('express'); +const path = require('path'); const read_1 = require("./read"); +const dir = path.dirname(require.main.filename); function containsAny(array, keys) { for (let i = 0; i < keys.length; i++) { if (array.indexOf(keys[i]) != -1) @@ -53,7 +55,7 @@ class Translucid { else res.sendFile(prev); }); - decorated[0]((!sendFiles) ? readResults : `${__dirname}/../../${filepath}`); + decorated[0]((!sendFiles) ? readResults : `${dir}/${filepath}`); }); } } diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts index 667d9c9..81a9baf 100644 --- a/typescript/translucid/Translucid.ts +++ b/typescript/translucid/Translucid.ts @@ -1,6 +1,9 @@ const express = require('express'); +const path = require('path'); import {read} from "./read"; +const dir = path.dirname(require.main.filename); + interface Middleware{ name:string; keys:Array; @@ -61,7 +64,7 @@ class Translucid { res.sendFile(prev); }); - decorated[0]((!sendFiles)?readResults:`${__dirname}/../../${filepath}`); + decorated[0]((!sendFiles)?readResults:`${dir}/${filepath}`); }); } }