raszi / node-tmp

Temporary file and directory creator for node.js
MIT License
736 stars 92 forks source link

no such file or directory #204

Closed Legends closed 4 years ago

Legends commented 4 years ago

Operating System

NodeJS Version

Tmp Version

TBD:0.1.0

Expected Behavior

TBD:What have you expected tmp to do? Create a file

Experienced Behavior

TBD:What did actually happen?

ENOENT: no such file or directory, open 'PARTIALS-INJECTOR\1layout.ejs' at Object.openSync (fs.js:440:3)

Example:

let i = 1;
    var fileOptions = {
        name: `${i}layout.ejs`,
        dir: "PARTIALS-INJECTOR"
    };

    // var dirObj = tmp.dirSync(dirOptions);
    var fileObj = tmp.fileSync(fileOptions);

The folder exists in the Temp folder.

silkentrance commented 4 years ago

Please have a look at the code here

https://github.com/raszi/node-tmp/blob/master/lib/tmp.js#L131

The dir option overrides the standard tmp directory and is considered relative to the current working directory or an absolute directory, if you pass in an absolute path starting with /.

If you need it to reside under the standard tmp directory, pass in

    var fileOptions = {
        ...
        dir: `${tmp.tmpdir}/PARTIALS-INJECTOR`
    };
Legends commented 4 years ago

Thanks!

silkentrance commented 4 years ago

related to #205 and #207 and #206