summaryrefslogtreecommitdiff
path: root/node_modules/fs-extra/lib/ensure/symlink.js
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2026-05-18 23:10:59 +0800
committerlittleblack111 <littleblack11111@gmail.com>2026-05-18 23:41:44 +0800
commitfc87c009806dcc98867f6b58efe29b042aa01dee (patch)
tree8f59b3f4a5b66e9dfef2d40c8d318e258a521228 /node_modules/fs-extra/lib/ensure/symlink.js
parent3336b2356ee6152d9c6ae59bd9b87ccbc0958407 (diff)
node: updatemain
Diffstat (limited to 'node_modules/fs-extra/lib/ensure/symlink.js')
-rw-r--r--node_modules/fs-extra/lib/ensure/symlink.js67
1 files changed, 0 insertions, 67 deletions
diff --git a/node_modules/fs-extra/lib/ensure/symlink.js b/node_modules/fs-extra/lib/ensure/symlink.js
deleted file mode 100644
index a3d5f578..00000000
--- a/node_modules/fs-extra/lib/ensure/symlink.js
+++ /dev/null
@@ -1,67 +0,0 @@
-'use strict'
-
-const u = require('universalify').fromPromise
-const path = require('path')
-const fs = require('../fs')
-
-const { mkdirs, mkdirsSync } = require('../mkdirs')
-
-const { symlinkPaths, symlinkPathsSync } = require('./symlink-paths')
-const { symlinkType, symlinkTypeSync } = require('./symlink-type')
-
-const { pathExists } = require('../path-exists')
-
-const { areIdentical } = require('../util/stat')
-
-async function createSymlink (srcpath, dstpath, type) {
- let stats
- try {
- stats = await fs.lstat(dstpath)
- } catch { }
-
- if (stats && stats.isSymbolicLink()) {
- const [srcStat, dstStat] = await Promise.all([
- fs.stat(srcpath),
- fs.stat(dstpath)
- ])
-
- if (areIdentical(srcStat, dstStat)) return
- }
-
- const relative = await symlinkPaths(srcpath, dstpath)
- srcpath = relative.toDst
- const toType = await symlinkType(relative.toCwd, type)
- const dir = path.dirname(dstpath)
-
- if (!(await pathExists(dir))) {
- await mkdirs(dir)
- }
-
- return fs.symlink(srcpath, dstpath, toType)
-}
-
-function createSymlinkSync (srcpath, dstpath, type) {
- let stats
- try {
- stats = fs.lstatSync(dstpath)
- } catch { }
- if (stats && stats.isSymbolicLink()) {
- const srcStat = fs.statSync(srcpath)
- const dstStat = fs.statSync(dstpath)
- if (areIdentical(srcStat, dstStat)) return
- }
-
- const relative = symlinkPathsSync(srcpath, dstpath)
- srcpath = relative.toDst
- type = symlinkTypeSync(relative.toCwd, type)
- const dir = path.dirname(dstpath)
- const exists = fs.existsSync(dir)
- if (exists) return fs.symlinkSync(srcpath, dstpath, type)
- mkdirsSync(dir)
- return fs.symlinkSync(srcpath, dstpath, type)
-}
-
-module.exports = {
- createSymlink: u(createSymlink),
- createSymlinkSync
-}