fsep
Version:
Fsep is a library that promisifies the native node FS operation and brings extras into the mix.
25 lines (15 loc) • 445 B
JavaScript
;
const Fs = require('fs');
const Path = require('path');
const Util = require('util');
const Exist = require('./exist');
const Mkdirs = require('./mkdirs');
const Symlink = Util.promisify(Fs.symlink);
module.exports = async function (source, target, type, mode) {
const path = Path.dirname(target);
await Mkdirs(path, mode);
const exist = await Exist(target);
if (!exist) {
await Symlink(source, target, type);
}
};