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,oBACE,SAAS,EAAM,GACZ,EAAE,uBACL,QAAQ,EAAM,UAEd,WAAW,SACX,UAAU,EAAM,GACxB,EAGF,OAAO,QAAQ","file":"/npm/@wrote/clone@1.2.1/build/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/@wrote/clone@1.2.1/build/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","let ensurePath = require('@wrote/ensure-path'); if (ensurePath && ensurePath.__esModule) ensurePath = ensurePath.default;\nlet readDirStructure = require('@wrote/read-dir-structure'); if (readDirStructure && readDirStructure.__esModule) readDirStructure = readDirStructure.default;\nlet makePromise = require('makepromise'); if (makePromise && makePromise.__esModule) makePromise = makePromise.default;\nconst {\n  createReadStream, createWriteStream, lstat, readlink, symlink,\n} = require('fs');\nconst { join, basename } = require('path');\n\n/**\n * Clone a file.\n * @param {string} from Path to the file which to clone.\n * @param {string} to Path to the file where to clone.\n */\nconst cloneFile = async (from, to) => {\n  const rs = createReadStream(from)\n  const ws = createWriteStream(to)\n  rs.pipe(ws)\n  await Promise.all([\n    new Promise((r, j) => {\n      rs.on('close', r).on('error', j)\n    }),\n    new Promise((r, j) => {\n      ws.on('close', r).on('error', j)\n    }),\n  ])\n}\n\nconst cloneLn = async (from, to) => {\n  const target = await makePromise(readlink, from)\n  await makePromise(symlink, [target, to])\n}\n\n/**\n * Clones a directory.\n * @param {string} from Path of the file or directory being cloned.\n * @param {string} to Path to the cloned directory (not its parent!).\n */\nconst cloneDir = async (from, to) => {\n  await ensurePath(join(to, 'path.file'))\n  const { content } = await readDirStructure(from)\n  const pr = Object.keys(/** @type {!Object} */ (content)).map(async (k) => {\n    const { type } = content[k]\n    const p = join(from, k)\n    const pt = join(to, k)\n    if (type == 'Directory') {\n      await cloneDir(p, pt)\n    } else if (type == 'File') {\n      await cloneFile(p, pt)\n    } else if (type == 'SymbolicLink') {\n      await cloneLn(p, pt)\n    }\n  })\n  await Promise.all(pr)\n}\n\n/**\n * Clone a file or directory.\n * @param {string} path Path to the file or directory to clone.\n * @param {string} to Path to the directory to contain the file or directory being cloned (not the path to the cloned entity).\n */\nconst clone = async (path, to) => {\n  const s = /** @type {!fs.Stats} */ (await makePromise(lstat, path))\n  const b = basename(path)\n  const t = join(to, b)\n\n  if (s.isDirectory()) {\n    await cloneDir(path, t)\n  } else if (s.isSymbolicLink()) {\n    await cloneLn(path, t)\n  } else {\n    await ensurePath(t)\n    await cloneFile(path, t)\n  }\n}\n\nmodule.exports=clone\n\n/**\n * @suppress {nonStandardJsDocs}\n * @typedef {import('fs').Stats} fs.Stats\n */"]}