Skip to content

Fix windows compatibility Issue #207 #241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 12, 2019
Merged
Show file tree
Hide file tree
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
10 changes: 6 additions & 4 deletions src/utils/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ function stripExtension(filePath: string) {
}

async function cmdShim(src: string, dest: string) {
const currentShimTarget = path.resolve(
path.dirname(src),
await readCmdShim(src)
);
// If not a symlink we default to the actual src file
// https://github.com/npm/npm/blob/d081cc6c8d73f2aa698aab36605377c95e916224/lib/utils/gently-rm.js#L273
let relativeShimTarget = await readlink(src);
let currentShimTarget = relativeShimTarget
? path.resolve(path.dirname(src), relativeShimTarget)
: src;
await promisify(cb => _cmdShim(currentShimTarget, stripExtension(dest), cb));
}

Expand Down
29 changes: 13 additions & 16 deletions src/utils/symlinkPackageDependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default async function symlinkPackageDependencies(

/*********************************************************************
* Calculate all the external dependencies that need to be symlinked *
**********************************************************************/
*********************************************************************/

directoriesToCreate.push(pkg.nodeModules, pkg.nodeModulesBin);

Expand Down Expand Up @@ -87,7 +87,7 @@ export default async function symlinkPackageDependencies(

/*********************************************************************
* Calculate all the internal dependencies that need to be symlinked *
**********************************************************************/
*********************************************************************/

for (let dependency of internalDeps) {
let depWorkspace = dependencyGraph.get(dependency) || {};
Expand All @@ -101,9 +101,9 @@ export default async function symlinkPackageDependencies(
throw new BoltError('Cannot symlink invalid set of dependencies.');
}

/********************************************************
/*********************************************************
* Calculate all the bin files that need to be symlinked *
*********************************************************/
*********************************************************/
let projectBinFiles = await fs.readdirSafe(project.pkg.nodeModulesBin);

// TODO: For now, we'll search through each of the bin files in the Project and find which ones are
Expand All @@ -118,14 +118,11 @@ export default async function symlinkPackageDependencies(
// read the symlink to find the actual bin file (path will be relative to the symlink)
let actualBinFileRelative = await fs.readlink(binPath);

if (!actualBinFileRelative) {
throw new BoltError(`${binName} is not a symlink`);
}

let actualBinFile = path.join(
project.pkg.nodeModulesBin,
actualBinFileRelative
);
// If not a symlink we default to the actual src file
// https://github.com/npm/npm/blob/d081cc6c8d73f2aa698aab36605377c95e916224/lib/utils/gently-rm.js#L273
let actualBinFile = actualBinFileRelative
? path.join(project.pkg.nodeModulesBin, actualBinFileRelative)
: binPath;

// To find the name of the dep that created the bin we'll get its path from node_modules and
// use the first one or two parts (two if the package is scoped)
Expand All @@ -149,9 +146,9 @@ export default async function symlinkPackageDependencies(
});
}

/*****************************************************************
/******************************************************************
* Calculate all the internal bin files that need to be symlinked *
******************************************************************/
******************************************************************/

// TODO: Same as above, we should really be making sure we get all the transitive bins as well

Expand Down Expand Up @@ -192,9 +189,9 @@ export default async function symlinkPackageDependencies(
}
}

/**********************************
/***********************************
* Create directories and symlinks *
***********************************/
***********************************/

await yarn.runIfExists(pkg, 'preinstall');

Expand Down