How to use the symlinkSync function from fs-extra

Find comprehensive JavaScript fs-extra.symlinkSync code examples handpicked from public code repositorys.

58
59
60
61
62
63
64
65
66
67
let symlink_path = '';
readStream.on('data', function(c) {
  symlink_path += c;
});
readStream.on('end', function() {
  fs.symlinkSync(symlink_path, path.join(dest, entry.fileName));
  return resolve();
});
readStream.on('error', function(err) {
  if (err) return reject(err);
fork icon169
star icon0
watch icon2

324
325
326
327
328
329
330
331
332
        do {
            _link = `${_name}-${_ext.replace(/\./g, "")}-${nanoid()}.js`
            _link = path.join(path.dirname(mnfst_path), _link)    
        } while (fs.existsSync(_link));

        fs.symlinkSync(_path, _link);
        _path = _link;
    }    
}
fork icon6
star icon21
watch icon3

+ 4 other calls in file

126
127
128
129
130
131
132
133
134
135
let linkCustomNodes = (details) => {
    console.log("linkCustomNodes");
    return new Promise((resolve, reject) => {
        details.customNodes.forEach((nodes) => {
            try {
                fs.symlinkSync(nodes.path, path.join(details.userDir, "node_modules", nodes.name));
            } catch (err) {
                console.log(err);
                reject("Error : Linking Custom Node failed for ", err);
            }
fork icon0
star icon2
watch icon0

7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
      opts.recursive = true
      copySync(path.join(src, content), path.join(dest, content), opts)
    })
  } else if (options.recursive && stats.isSymbolicLink() && performCopy) {
    const srcPath = fs.readlinkSync(src)
    fs.symlinkSync(srcPath, dest)
  }
}


module.exports = copySync
fork icon0
star icon1
watch icon0

+ 26 other calls in file

145
146
147
148
149
150
151
152
153
154
update.client = "local";

Blog.set(id, update, function (err) {
  if (err) return next(err);
  fs.removeSync(localPath(id, "/").slice(0, -1));
  fs.symlinkSync(path, localPath(id, "/").slice(0, -1));
  client.publish(
    "clients:local:new-folder",
    JSON.stringify({ blogID: id }),
    function (err) {
fork icon69
star icon0
watch icon23

+ 4 other calls in file

26
27
28
29
30
31
32
33
34
35
36
                throw new Error(`'${targetPath}' is already linked to another directory`);
            }
        }


        fs.moveSync(sourcePath, targetPath);
        fs.symlinkSync(targetPath, sourcePath, "junction");
        console.log(`Linked ${sourcePath} <==> ${targetPath}`);
    }
})().catch(error => {
    console.error(error);
fork icon1
star icon0
watch icon1

+ 9 other calls in file

1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
if (useLinks) {
    try {
        if (onWindows) {
            fs.linkSync(fullModelPath, linkPath);
        } else {
            fs.symlinkSync(fullModelPath, linkPath, 'file');
        }
    } catch(err) {
        console.error(err);
        console.warn(`Failed to create ${onWindows ? 'hard' : 'symbolic'} link. Falling back to file copying`);
fork icon0
star icon0
watch icon1

+ 14 other calls in file

41
42
43
44
45
46
47
48
49
50
                    console.log(`Linked ${sourcePath} <==> ${targetPath}`);
                });
            }
        } else {
            fs.moveSync(sourcePath, targetPath);
            fs.symlinkSync(targetPath, sourcePath, 'junction');
            console.log(`Linked ${sourcePath} <==> ${targetPath}`);
        }
    }
})().catch(error => {
fork icon0
star icon0
watch icon1

+ 23 other calls in file

function icon

fs-extra.readFileSync is the most popular function in fs-extra (9724 examples)