fs.existSync returns true after fs. symlinkSync node 10 onwards in windows only
Hi,
I started seeing a difference in behavior when I run the following code in Linux and Windows in node 10 and node 12.
const fs = require('fs'); console.log(`Before symlink: ${fs.existsSync('linkHere')}`); fs.symlinkSync('test/foo.js', 'linkHere'); console.log(`After symlink: ${fs.existsSync('linkHere')}`); console.log(`issymlink: ${fs.lstatSync('linkHere').isSymbolicLink()}`); //cleanup fs.unlinkSync('linkHere');
I created reproduction repo and travis, appveyor CI to show the difference.
Please check the output of the above snippet;
- node 8
- linux
$ node --version v8.16.2 > node index.js Before symlink: false After symlink: false issymlink: true
- windows
$ node index.js Before symlink: false After symlink: false issymlink: true
- node 10
- linux
$ node --version v10.17.0 > node index.js Before symlink: false After symlink: false issymlink: true
- windows
Installing node 10.17.0 (x86)... $ node index.js Before symlink: false After symlink: true issymlink: true
I am not sure why are we getting different result for same code in windows and Linux? Is it a bug or am I missing something.
Reproduction repo: https://github.com/SparshithNR/node-symlink
Travis build: https://travis-ci.com/SparshithNR/node-symlink/builds/137133722
appveyor build: https://ci.appveyor.com/project/SparshithNR/node-symlink
Thank you in advance :)