From f2a39ad6c65b8ef9a92b3f73bdbd45d6d102b2d6 Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Tue, 30 Jul 2019 11:59:56 +0300 Subject: [PATCH] feature: add sync-build arg --- README.md | 6 ++++++ package.json | 2 +- src/angular.js | 10 +++++++--- src/cli.js | 8 +++++--- src/link-with-config.js | 6 +++++- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4494679..7bdb76f 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/package.json b/package.json index 1a6d18a..a5ec55d 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/angular.js b/src/angular.js index 38e85cc..f12e021 100644 --- a/src/angular.js +++ b/src/angular.js @@ -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); @@ -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]); } diff --git a/src/cli.js b/src/cli.js index 2d8efb9..c3a85ae 100644 --- a/src/cli.js +++ b/src/cli.js @@ -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', }, @@ -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] || '', }; } diff --git a/src/link-with-config.js b/src/link-with-config.js index c5f8715..91e97cc 100644 --- a/src/link-with-config.js +++ b/src/link-with-config.js @@ -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();