rebuild() {
    fs.rmdirSync(this.outputPath);

    // TODO: investigate if we can use rename the directory instead to improve performance on
    // Windows
    symlinkOrCopy.sync(this.inputPath, this.outputPath);
  }
Example #2
0
export function symlinkOrReplaceSync(srcPath: string, destDir: string, fileName: string): void {
  const destPath = path.join(destDir, fileName);
  if (fs.existsSync(destPath)) {
    fs.unlinkSync(destPath);
  }
  mkdirpSync(destDir);
  symlinkOrCopySync(srcPath, destPath);
}
    pathsToUpdate.forEach((changedFilePath) => {
      var sourceFilePath = path.join(this.inputPath, changedFilePath);
      var destFilePath = path.join(this.cachePath, path.basename(changedFilePath));
      var destDirPath = path.dirname(destFilePath);

      if (!fs.existsSync(destDirPath)) {
        fse.mkdirpSync(destDirPath);
      }

      if (!fs.existsSync(destFilePath)) {
        symlinkOrCopy(sourceFilePath, destFilePath);
      } else {
        throw new Error(`Duplicate file '${path.basename(changedFilePath)}' ` +
                        `found in path '${changedFilePath}'`);
      }
    });
import * as symlinkOrCopy from 'symlink-or-copy';

symlinkOrCopy.sync('src_dir/some_file.txt', 'dest_dir/some_file.txt');

symlinkOrCopy.canSymlink; // $ExpectType boolean
symlinkOrCopy.canSymlinkDirectory; // $ExpectType boolean
symlinkOrCopy.canSymlinkFile; // $ExpectType boolean