Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,31 +109,37 @@
.on('error', reject)
.on('entry', (header, stream, next) => {
stream.on('end', next);
const destFilePath = path.join(destDir, header.name);

if (header.type === 'file') {
const fullpath = path.join(destDir, header.name);
mkdirp(path.dirname(fullpath), err => {
const dir = path.dirname(destFilePath);
mkdirp(dir, err => {
if (err) return reject(err);

entryCount++;
pump(stream, fs.createWriteStream(fullpath, { mode: opts.mode || header.mode }), err => {
pump(stream, fs.createWriteStream(destFilePath, { mode: opts.mode || header.mode }), err => {
if (err) return reject(err);
successCount++;
done();
});
});
} else if (header.type === 'symlink') {
// symlink
const src = path.join(destDir, header.name);
const target = path.resolve(path.dirname(src), header.linkname);
const dir = path.dirname(destFilePath);
const target = path.resolve(dir, header.linkname);
entryCount++;
fs.symlink(target, src, err => {

mkdirp(dir, err => {
if (err) return reject(err);
successCount++;
stream.resume();

const relativeTarget = path.relative(dir, target);
fs.symlink(relativeTarget, destFilePath, err => {

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 14)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 14)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 16)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 16)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 24)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 24)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 24)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 24)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 16)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 16)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 24)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 24)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 16)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 16)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 14)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 14)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 14)

Use 'fs.promises.symlink()' instead

Check warning on line 135 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 14)

Use 'fs.promises.symlink()' instead
if (err) return reject(err);
successCount++;
stream.resume();
});
});
} else { // directory
mkdirp(path.join(destDir, header.name), err => {
mkdirp(destFilePath, err => {
if (err) return reject(err);
stream.resume();
});
Expand Down Expand Up @@ -175,7 +181,7 @@
return fileName;
}

exports.stripFileName = (strip, fileName, type) => {
function stripFileName(strip, fileName, type) {
// before
// node/package.json
// node/lib/index.js
Expand Down Expand Up @@ -218,4 +224,6 @@

strip = Math.min(strip, s.length - 1);
return s.slice(strip).join('/') || '/';
};
}

exports.stripFileName = stripFileName;
Loading