Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.

Commit

Permalink
Merge pull request #118 from activeviam/master
Browse files Browse the repository at this point in the history
Use `junction` type when symlinking directories on Windows
  • Loading branch information
Inkdpixels authored Jun 18, 2018
2 parents da58a22 + 9cec615 commit f2a9b55
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 28 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"inquirer": "5.2.0",
"lodash.merge": "^4.6.1",
"log-fancy": "1.3.2",
"make-symlinks": "1.1.0",
"micromatch": "3.1.10",
"yargs": "11.0.0"
},
Expand Down
4 changes: 1 addition & 3 deletions src/lib/dependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,7 @@ const dependencyUtils = {
return;
}

await file.createSymlink(src, distDir, {
force: true
});
await file.createSymlink(src, distDir);
}
};

Expand Down
15 changes: 12 additions & 3 deletions src/lib/file.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
// @flow

const fs = require('fs');
const makeSymlinks = require('make-symlinks');
const {basename, join} = require('path');
const {promisify} = require('util');
const logger = require('./logger.js');

const _utils = {
readFileAsync: promisify(fs.readFile),
writeFileAsync: promisify(fs.writeFile),
accessAsync: promisify(fs.access)
accessAsync: promisify(fs.access),
statAsync: promisify(fs.stat),
symlinkAsync: promisify(fs.symlink)
};

const fileUtils = {
_utils,

createSymlink: makeSymlinks,
async createSymlink(target: string, distDir: string) {
const dist = join(distDir, basename(target));
const stats = await _utils.statAsync(target);
// Use a junction on Windows like Yarn do.
// See: https://github.com/yarnpkg/yarn/blob/fc94a16b7ca90a188d084aef8cea406b60e8c38f/src/util/fs.js#L695-L696
const type = stats.isDirectory() ? 'junction' : 'file';
await _utils.symlinkAsync(target, dist, type);
},

/**
* Asynchronously checks if a file exists or not.
Expand Down
23 changes: 2 additions & 21 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ define-property@^2.0.2:
is-descriptor "^1.0.2"
isobject "^3.0.1"

del@^2.0.2, del@^2.2.2:
del@^2.0.2:
version "2.2.2"
resolved "https://registry.yarnpkg.com/del/-/del-2.2.2.tgz#c12c981d067846c84bcaf862cff930d907ffd1a8"
dependencies:
Expand Down Expand Up @@ -2495,16 +2495,6 @@ globby@^5.0.0:
pify "^2.0.0"
pinkie-promise "^2.0.0"

globby@^6.1.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/globby/-/globby-6.1.0.tgz#f5a6d70e8395e21c858fb0489d64df02424d506c"
dependencies:
array-union "^1.0.1"
glob "^7.0.3"
object-assign "^4.0.1"
pify "^2.0.0"
pinkie-promise "^2.0.0"

got@^7.1.0:
version "7.1.0"
resolved "https://registry.yarnpkg.com/got/-/got-7.1.0.tgz#05450fd84094e6bbea56f451a43a9c289166385a"
Expand Down Expand Up @@ -3917,15 +3907,6 @@ lru-cache@^4.0.1:
pseudomap "^1.0.2"
yallist "^2.1.2"

make-symlinks@1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/make-symlinks/-/make-symlinks-1.1.0.tgz#c6a05b0c60048a6c4dfe92b85b12f83a480b55c8"
dependencies:
del "^2.2.2"
globby "^6.1.0"
pify "^2.3.0"
pinkie-promise "^2.0.1"

makeerror@1.0.x:
version "1.0.11"
resolved "https://registry.yarnpkg.com/makeerror/-/makeerror-1.0.11.tgz#e01a5c9109f2af79660e4e8b9587790184f5a96c"
Expand Down Expand Up @@ -4603,7 +4584,7 @@ pify@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176"

pinkie-promise@^2.0.0, pinkie-promise@^2.0.1:
pinkie-promise@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa"
dependencies:
Expand Down

0 comments on commit f2a9b55

Please sign in to comment.