Skip to content

Commit

Permalink
fix: bug of get linkedModules
Browse files Browse the repository at this point in the history
  • Loading branch information
bluelovers committed Jun 6, 2020
1 parent adf318e commit dd9bc3c
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 25 deletions.
32 changes: 21 additions & 11 deletions packages/@yarn-tool/fix-ws-links/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 26 additions & 12 deletions packages/@yarn-tool/fix-ws-links/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export function fixYarnWorkspaceLinks(cwd?: string, options?: {

let verbose = options.verbose;

verbose && console.debug('[linkedModules]', links);

if (sublist.length)
{

Expand All @@ -57,27 +59,36 @@ export function fixYarnWorkspaceLinks(cwd?: string, options?: {

let is_same = sameRealpath(location, row.location)

if (location && is_same === false && !isSymbolicLink(row.location))
let is_symlink = isSymbolicLink(row.location);

if (location && is_same === false && !is_symlink)
{
try
if (links.includes(name))
{
unlinkSync(row.location);
linkSync(location, row.location);

console.success(`create link`, row.name, `=>`, location)
add_links.push(name)
}
catch (e)
else
{
verbose && console.error(e.toString());
_error = true;
try
{
unlinkSync(row.location);
linkSync(location, row.location);

if (links.includes(name))
console.success(`create link`, row.name, `=>`, location)
}
catch (e)
{
add_links.push(name)
verbose && console.error(e.toString());
_error = true;

if (links.includes(name))
{
add_links.push(name)
}
}
}
}
else if (links.includes(name))
else if (!is_symlink && links.includes(name))
{
add_links.push(name)
}
Expand All @@ -91,6 +102,9 @@ export function fixYarnWorkspaceLinks(cwd?: string, options?: {

if (add_links.length)
{
verbose && console.debug('link', [
...add_links,
]);
crossSpawn.sync('yarn', [
`link`,
...add_links,
Expand Down
3 changes: 2 additions & 1 deletion packages/yarn-list-link/core.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion packages/yarn-list-link/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export function yarnListLinkCore(cwd: string): string[]

if (existsSync(file))
{
let { linkedModules = [] as string[] } = readJSONSync(file).linkedModules
let json = readJSONSync(file);
let { linkedModules = [] as string[] } = json

return linkedModules
.map(v => normalize(v))
;
Expand Down

0 comments on commit dd9bc3c

Please sign in to comment.