Skip to content

Commit 0b6b96f

Browse files
Update build version and add fix for file manipulation issue (#2154)
Fixes file manipulations Fixes #2144
1 parent da638f5 commit 0b6b96f

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "traceur",
3-
"version": "0.0.112",
3+
"version": "0.0.113",
44
"description": "ES6 to ES5 compiler",
55
"keywords": [
66
"javascript",

src/node/file-util.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,18 @@ function removeCommonPrefix(basedir, filedir) {
5353
function writeFile(filename, contents) {
5454
// Compute the output path
5555
var outputdir = fs.realpathSync(process.cwd());
56-
mkdirRecursive(path.dirname(filename));
57-
var filedir = fs.realpathSync(path.dirname(filename));
58-
filedir = removeCommonPrefix(outputdir, filedir);
59-
outputdir = path.join(outputdir, filedir);
56+
57+
// Resolve the full path of the target file
58+
var resolvedFilePath = path.resolve(outputdir, filename);
6059

61-
mkdirRecursive(outputdir);
62-
var outputfile = path.join(outputdir, path.basename(filename));
63-
fs.writeFileSync(outputfile, contents, 'utf8');
60+
// Ensure the parent directory of the target file exists
61+
var parentDir = path.dirname(resolvedFilePath);
62+
63+
// Only create the necessary parent directory structure
64+
mkdirRecursive(parentDir);
65+
66+
// Write the file
67+
fs.writeFileSync(resolvedFilePath, contents, 'utf8');
6468
}
6569

6670
function normalizePath(s) {

0 commit comments

Comments
 (0)