mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
The main motivation behind these changes is to rely on https://github.com/jprichardson/node-fs-extra/blob/8.1.0/docs/copy-sync.md as much as possible in order to avoid having to do the `fullFilePath.replace(srcDir, '')` operation because this operation can be error-prone. Doing so fixes the following issues because the user-submitted file paths are now correctly interpreted by fs-extra, closing both #6525 and #5172.
17 lines
412 B
JavaScript
17 lines
412 B
JavaScript
'use strict';
|
|
|
|
const fs = require('fs');
|
|
const fse = require('./fse');
|
|
|
|
const isNotSymbolicLink = src => !fs.lstatSync(src).isSymbolicLink();
|
|
|
|
function copyDirContentsSync(srcDir, destDir, { noLinks = false } = {}) {
|
|
const copySyncOptions = {
|
|
dereference: true,
|
|
filter: noLinks ? isNotSymbolicLink : null,
|
|
};
|
|
fse.copySync(srcDir, destDir, copySyncOptions);
|
|
}
|
|
|
|
module.exports = copyDirContentsSync;
|