Skip to content

Commit

Permalink
feature: add sync-build arg
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmet-erim committed Jul 30, 2019
1 parent b48ec2c commit f2a39ad
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ Symlink-manager can take your packages on command.
yarn symlink --packages my-package-1,my-package-2 --no-watch
```

If building order matters, you can pass --sync-build

```bash
yarn symlink --sync-build
```

If you are not using Angular, you must add symlink.config.json for your configuration.

symlink.config.json example:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "symlink-manager",
"version": "1.2.1",
"version": "1.2.2",
"description": "Symlink Manager easily manage to symbolic link processes of your dependency packages.",
"main": "index.js",
"scripts": {
Expand Down
10 changes: 7 additions & 3 deletions src/angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ export default async function(options) {
spinner.start();

try {
await build(packageManager, projectName);
if (options.syncBuild) {
execa.sync(packageManager, [...(packageManager === 'npm' ? ['run'] : []), 'ng', 'build', projectName]);
} else {
await build(packageManager, projectName);
}
} catch (error) {
spinner.stop();
Log.error(error.stderr);
Expand Down Expand Up @@ -172,6 +176,6 @@ function getOutputFolder(ngPackagePath) {
return path.normalize(`${ngPackagePath}/../${ngPackage.dest}`);
}

async function build(packageManager, projectName, params) {
await execa(packageManager, [...(packageManager === 'npm' ? ['run'] : []), 'ng', 'build', projectName], params);
async function build(packageManager, projectName) {
await execa(packageManager, [...(packageManager === 'npm' ? ['run'] : []), 'ng', 'build', projectName]);
}
8 changes: 5 additions & 3 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ function parseArgumentsIntoOptions(rawArgs) {
const args = arg(
{
'--angular': Boolean,
'--yarn': Boolean,
'--no-watch': Boolean,
'--packages': String,
'--sync-build': Boolean,
'--yarn': Boolean,
'-a': '--angular',
'-y': '--yarn',
},
Expand All @@ -22,10 +23,11 @@ function parseArgumentsIntoOptions(rawArgs) {
},
);
return {
yarn: args['--yarn'],
angular: args['--angular'],
packages: args['--packages'],
noWatch: args['--no-watch'],
packages: args['--packages'],
syncBuild: args['--sync-build'],
yarn: args['--yarn'],
command: args._[0] || '',
};
}
Expand Down
6 changes: 5 additions & 1 deletion src/link-with-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ export default async function(options, config) {
if (options.command === 'link' || options.command === 'copy') {
if (pack.buildCommand) {
try {
await execa(buildCommandArr[0], buildCommandArr.slice(1), { cwd: pack.buildCommandRunPath || './' });
if (options.syncBuild) {
execa.sync(buildCommandArr[0], buildCommandArr.slice(1), { cwd: pack.buildCommandRunPath || './' });
} else {
await execa(buildCommandArr[0], buildCommandArr.slice(1), { cwd: pack.buildCommandRunPath || './' });
}
Log.success(`\n${packName} successfully built.`);
} catch (error) {
spinner.stop();
Expand Down

0 comments on commit f2a39ad

Please sign in to comment.