Skip to content

Commit a614b58

Browse files
authored
Merge pull request #1 from stickeepaul/add-silent-mode-to-npm-task
Add silent argument to npm task
2 parents 2df54ae + e461adf commit a614b58

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

doc/tasks/npm_script.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ parameters:
1212
triggered_by: [js, jsx, coffee, ts, less, sass, scss]
1313
working_directory: "./"
1414
is_run_task: false
15+
silent: false
1516
```
1617
1718
**script**
@@ -46,3 +47,9 @@ This option specifies in which directory the NPM script should be run.
4647
*Default: false*
4748
4849
This option will append 'run' to the npm command to make it possible to run custom npm scripts.
50+
51+
**silent**
52+
53+
*Default: false*
54+
55+
This option will append '--silent' to the npm script to supress `npm ERR!` messages from showing.

src/Task/NpmScript.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ public function getConfigurableOptions(): OptionsResolver
2929
'triggered_by' => ['js', 'jsx', 'coffee', 'ts', 'less', 'sass', 'scss'],
3030
'working_directory' => './',
3131
'is_run_task' => false,
32+
'silent' => false,
3233
]);
3334

3435
$resolver->addAllowedTypes('script', ['string']);
3536
$resolver->addAllowedTypes('triggered_by', ['array']);
3637
$resolver->addAllowedTypes('working_directory', ['string']);
3738
$resolver->addAllowedTypes('is_run_task', ['bool']);
39+
$resolver->addAllowedTypes('silent', ['bool']);
3840

3941
return $resolver;
4042
}
@@ -61,6 +63,7 @@ public function run(ContextInterface $context): TaskResultInterface
6163
$arguments = $this->processBuilder->createArgumentsForCommand('npm');
6264
$arguments->addOptionalArgument('run', $config['is_run_task']);
6365
$arguments->addRequiredArgument('%s', $config['script']);
66+
$arguments->addOptionalArgument('--silent', $config['silent']);
6467

6568
$process = $this->processBuilder->buildProcess($arguments);
6669
$process->setWorkingDirectory(realpath($config['working_directory']));

0 commit comments

Comments
 (0)