Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit d2a013b

Browse files
authored
chore: Launch script for demo-app (#2247)
Usage: `yarn demo-app` from root folder. closes #2236
1 parent 1768c6a commit d2a013b

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

docs/developer.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111
4. Clone your fork to your machine with `git clone`.
1212
5. From the root of the project, run `yarn` to install the dependencies.
1313

14-
## <a name="setupdemos"></a> Install demo dependencies
15-
Change path to `/demos`, run `yarn` to install dependencies.
16-
1714
## <a name="demo-server"></a> Run demo application
18-
Change path to `/demos`, run `yarn start`.
19-
15+
From the root of the project,
16+
```
17+
yarn demo-app
18+
```
2019
After your development server is running, open a browser to url: http://localhost:4200
2120

2221
## <a name="lint"></a> Linting

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"bazel:buildifier": "find . -type f \\( -name \"*.bzl\" -or -name WORKSPACE -or -name BUILD -or -name BUILD.bazel \\) ! -path \"*/node_modules/*\" | xargs buildifier -v --warnings=attr-cfg,attr-license,attr-non-empty,attr-output-default,attr-single-file,constant-glob,ctx-args,depset-iteration,depset-union,dict-concatenation,duplicated-name,filetype,git-repository,http-archive,integer-division,load,load-on-top,native-build,native-package,output-group,package-name,package-on-top,redefined-variable,repository-name,same-origin-load,string-iteration,unused-variable,unsorted-dict-items,out-of-order-load",
2020
"bazel:format-lint": "yarn -s bazel:buildifier --lint=warn --mode=check",
2121
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
22+
"demo-app": "node ./scripts/run-demo-app.js",
2223
"lint": "yarn -s tslint && yarn -s bazel:format-lint",
2324
"tslint": "tslint -c tslint.json --project ./tsconfig.json",
2425
"lint:css": "stylelint \"packages/material-components-web/**/*.scss\"",

scripts/run-demo-app.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Script that runs the demo-app.
5+
*/
6+
7+
const {execSync} = require('child_process');
8+
const {set, cd} = require('shelljs');
9+
const {join} = require('path');
10+
11+
// ShellJS should throw if any command fails.
12+
set('-e');
13+
14+
/** Path to the demo directory. */
15+
const projectDirPath = join(__dirname, '../demos');
16+
17+
// Go to demos directory.
18+
cd(projectDirPath);
19+
20+
// Check if dependencies are installed, run demo-app.
21+
exec('yarn && yarn start');
22+
23+
function exec(command, captureStdout) {
24+
const stdout = execSync(command, {
25+
cwd: projectDirPath,
26+
stdio: ['inherit', captureStdout ? 'pipe' : 'inherit', 'inherit'],
27+
});
28+
29+
if (captureStdout) {
30+
process.stdout.write(stdout);
31+
return stdout.toString().trim();
32+
}
33+
}

0 commit comments

Comments
 (0)