I have an uglify
function that creates a file lib-0.1.4-min.js
and then symlinks that to lib-production-min.js
. 0.1.4
is the current version.
due to synchronization of this directory, sometimes the lib-production-min.js
is a broken link.
when I run the compile function, fs.existsSync( "lib-production-min.js" )
returns false. when I try to create the symlink later, node
errs out with file already exists
.
var version = 'lib-0.1.4-min.j';
var prod = 'lib-production-min.js';
// if production exists, get rid of it
if( fs.existsSync(prod) ) fs.unlinkSync( prod ); // not exists - not deleted
// link version to production
fs.symlinkSync( version, prod ); // ERROR: file already exists
how do I check if this deadlink is in the directory?
will normal fs.unlinkSync( "lib-production-min.js" )
delete it?
You can “undo” the effects of npm link by simply removing the symbolic links. But there is a built in command for it, aptly called: npm unlink . Just run npm unlink --no-save <module_name> on your project's directory to remove the local symlink, and run npm unlink on the module's directory to remove the global symlink.
Conclusion. To remove a symbolic link, use either the rm or unlink command followed by the name of the symlink as an argument. When removing a symbolic link that points to a directory do not append a trailing slash to the symlink name.
No. The symlink system call will return EEXIST if newpath already exists. You can only link from a new node in the filesystem.
Yes. You can only stack so much symbolic links together before the kernel and/or application refuse to follow the chain.
fs.lstat()
or fs.lstatSync()
might help you. They are supposed to bring the information about the link itself, not following it.
Use fs.readlinkSync(symlinkPath)
to get the file pointed by the symlink, and then use fs.existsSync
with that path.
The problem is that the link file exists, is the destination of the link the one that is missing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With