Urara-Blog/node_modules/.pnpm-store/v3/files/ac/e918ff301d11f12e1899308afe9fb8e8d0084ccbd28fb409e58345b21ebeff8290b5335d4bb398e44849ed51349845c88988d57bb62fddb6c02935009d7039
2022-08-14 01:14:53 +08:00

40 lines
No EOL
1.1 KiB
Text

import { stat, statSync } from '../sander';
import { copydir, copydirSync } from './copydir';
import { copyFile, copyFileSync } from './copyFile';
import { symlink, symlinkSync } from '../specialMethods/symlink';
import resolvePathAndOptions from '../utils/resolvePathAndOptions';
const isWindows = process.platform === 'win32';
export function symlinkOrCopy () {
if ( isWindows ) {
const { resolvedPath: src, options: readOptions } = resolvePathAndOptions( arguments );
let copyDirOrFileTo = stat( src )
.then( stats => {
return ( stats.isDirectory() ? copydir : copyFile )
.apply( null, arguments )
.to;
});
return {
to () {
return copyDirOrFileTo
.then(fn => {
return fn.apply(null, arguments);
});
}
};
}
return symlink.apply( null, arguments );
}
export function symlinkOrCopySync () {
if ( isWindows ) {
const { resolvedPath: src, options: readOptions } = resolvePathAndOptions( arguments );
return ( statSync( src ).isDirectory() ? copydirSync : copyFileSync ).apply( null, arguments );
}
return symlinkSync.apply( null, arguments );
}