-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
examples: add
npm run example
script
a bad result from adding the examples as dependencies of the root repository is that they now don't have access to the npm binaries they need to run in their own folder, because they are installed into the root repository instead. this works around that issue. we may need to consider undoing that change and making the examples work as standalone projects again, that's easier to understand. fixes #2024 for now.
- Loading branch information
1 parent
564c500
commit 7b2283d
Showing
16 changed files
with
308 additions
and
109 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,29 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* Lerna installs all the example dependencies into the root `node_modules`. | ||
* To run the examples they need to have access to executables from npm dependencies in their $PATH. | ||
* If you run `npm start` in a dependency folder, the root `node_modules/.bin` is not in the $PATH. | ||
* | ||
* This proxy executable can be run from the repository root using `npm run example`, so the root | ||
* `node_modules/.bin` will be in the $PATH. It then runs `npm start` in the specific example folder, | ||
* which will inherit the $PATH, so the example has access to executables from npm dependencies in both | ||
* its own and in the root `node_modules`. | ||
*/ | ||
|
||
const path = require('path') | ||
const { execSync } = require('child_process') | ||
const exampleName = process.argv[2] | ||
|
||
if (!exampleName) { | ||
console.error('Usage: npm run example "name-of-example"') | ||
process.exit(1) | ||
} | ||
|
||
const exampleDir = path.join(__dirname, '../examples', exampleName) | ||
const pkg = require(path.join(exampleDir, 'package.json')) | ||
if (pkg.scripts && pkg.scripts.build) { | ||
execSync('npm run build', { cwd: exampleDir, stdio: 'inherit' }) | ||
} | ||
|
||
execSync('npm start', { cwd: exampleDir, stdio: 'inherit' }) |
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
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 |
---|---|---|
@@ -1,18 +1,17 @@ | ||
# Multiple Instances | ||
|
||
This example uses Uppy with the RestoreFiles plugin. | ||
This example uses Uppy with the `@uppy/golden-retriever` plugin. | ||
It has two instances on the same page, side-by-side, but with different `id`s so their stored files don't interfere with each other. | ||
|
||
## Run it | ||
|
||
To run this example, make sure you've correctly installed the root repository: | ||
|
||
To run this example, make sure you've correctly installed the **repository root**: | ||
```bash | ||
npm install | ||
``` | ||
That will also install the dependencies for this example. | ||
|
||
Move into this directory, then: | ||
|
||
Then, again in the **repository root**, start this example by doing: | ||
```bash | ||
npm start | ||
npm run example multiple-instances | ||
``` |
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
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
Oops, something went wrong.
7b2283d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
太棒了