Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(link): generate shims for missing 'bin' scripts (#2059)
During the 'link' step, if a package's binary targets don't exist yet they will fail to be symlinked, even if a later `run xxx` step would have generated them. This is a situation that occurs in monorepos containing build tools compiled from another language (e.g. TypeScript). Simply adding the symlinks whether the target exists or not is not good enough, as the symlink target needs to be `chmod +x`ed, which is lerna's/npm's responsibility. Instead, if the target doesn't exist, generate a shim shell script that will `chmod` and `exec` the intended target, similar to what would happen on Windows normally. Fixes #1444
- Loading branch information
Showing
10 changed files
with
80 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a-build-tool.js |
3 changes: 3 additions & 0 deletions
3
integration/__fixtures__/lerna-generated-build-tool/lerna.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"version": "1.0.0" | ||
} |
7 changes: 7 additions & 0 deletions
7
integration/__fixtures__/lerna-generated-build-tool/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "basic", | ||
"version": "monorepo", | ||
"private": true, | ||
"dependencies": { | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
integration/__fixtures__/lerna-generated-build-tool/packages/build-tool/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "@test/build-tool", | ||
"version": "1.0.0", | ||
"bin": { | ||
"a-build-tool": "a-build-tool.js" | ||
}, | ||
"scripts": { | ||
"build": "echo \"#!/usr/bin/env node\nconsole.log('build tool executed')\" > a-build-tool.js" | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
integration/__fixtures__/lerna-generated-build-tool/packages/buildable/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "@test/buildable", | ||
"version": "2.0.0", | ||
"devDependencies": { | ||
"@test/build-tool": "*" | ||
}, | ||
"scripts": { | ||
"build": "a-build-tool" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"use strict"; | ||
|
||
const cliRunner = require("@lerna-test/cli-runner"); | ||
const initFixture = require("@lerna-test/init-fixture")(__dirname); | ||
|
||
test("lerna link symlinks generated binaries of sibling packages", async () => { | ||
const cwd = await initFixture("lerna-generated-build-tool"); | ||
const lerna = cliRunner(cwd); | ||
|
||
// First bootstrap, I expect this to succeed but don't are about the output | ||
await lerna("bootstrap"); | ||
|
||
const { stdout } = await lerna("run", "build"); | ||
|
||
expect(stdout).toMatch("build tool executed"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters