From 5dd3e148397b522b2018f44b88ae46408197bfb0 Mon Sep 17 00:00:00 2001 From: pnlybubbles Date: Fri, 25 Sep 2015 13:05:54 +0900 Subject: [PATCH] fix relative path resolution problem --- index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 9be8b5b..1290b7a 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,7 @@ var _ = require('lodash'); var fs = require('fs'); var through = require('through2'); +var path = require('path'); function tsify(b, opts) { var ts = opts.typescript || require('typescript'); @@ -45,9 +46,15 @@ function tsify(b, opts) { function flush(next) { var self = this; var entries = rows - .map(function (row) { return row.file || row.id; }) + .map(function (row) { + if (row.basedir && (row.file || row.id)) { + return path.resolve(row.basedir, row.file || row.id); + } else { + return row.file || row.id; + } + }) .filter(function (file) { return file; }) - .map(function (file) { return fs.realpathSync(file) }); + .map(function (file) { return fs.realpathSync(file); }); tsifier.reset(); tsifier.generateCache(entries); rows.forEach(function (row) { self.push(row); });