nuclide-commons
Advanced tools
Comparing version 0.1.4 to 0.1.5
21
nice.js
@@ -104,13 +104,14 @@ 'use strict'; | ||
const NICE_COMMAND = 'nice'; /** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the license found in the LICENSE file in | ||
* the root directory of this source tree. | ||
* | ||
* | ||
* @format | ||
*/ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the license found in the LICENSE file in | ||
* the root directory of this source tree. | ||
* | ||
* | ||
* @format | ||
*/ | ||
const NICE_COMMAND = 'nice'; | ||
const IONICE_COMMAND = 'ionice'; | ||
@@ -117,0 +118,0 @@ |
{ | ||
"name": "nuclide-commons", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Common Nuclide node modules.", | ||
@@ -5,0 +5,0 @@ "license": "SEE LICENSE IN LICENSE", |
@@ -271,36 +271,3 @@ 'use strict'; | ||
*/ | ||
function runCommand(command, args = [], options = {}, rest) { | ||
return runCommandDetailed(command, args, options).map(event => event.stdout); | ||
} | ||
/** | ||
* Returns an observable that spawns a process and emits events on stdout, stderr and exit. Output | ||
* is buffered by line. Unsubscribing before the observable completes will kill the process. This | ||
* function accepts the same options as `runCommand()`, and throws the same errors. | ||
* | ||
* Besides emitting multiple events, another difference with `runCommand()` is the ProcessExitErrors | ||
* thrown by `observeProcess()`. Whereas ProcessExitErrors thrown by `runCommand()` contain the | ||
* entirety of stdout and stderr, those thrown by `observeProcess()` contain a truncated amount of | ||
* stderr and no stdout. This is because `observeProcess()` is usually used with long-running | ||
* processes that may continue to produce output for a long while. The abbreviated stderr is | ||
* included to help with debugging. | ||
* | ||
* Example: | ||
* | ||
* ```js | ||
* const filesToTail: Observable<NuclideUri> = f(); | ||
* const subscription = filesToTail | ||
* // `switchMap()` means only one file will be tailed at a time. | ||
* .switchMap(path => observeProcess('tail', ['-f', path])) | ||
* .filter(event => event.kind === 'stdout') | ||
* .map(event => event.data) | ||
* .subscribe(line => { | ||
* console.log(line); | ||
* }); | ||
* ``` | ||
*/ | ||
// TODO(T17266325): Replace this in favor of `atom.whenShellEnvironmentLoaded()` when it lands | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
@@ -354,2 +321,35 @@ * All rights reserved. | ||
function runCommand(command, args = [], options = {}, rest) { | ||
return runCommandDetailed(command, args, options).map(event => event.stdout); | ||
} | ||
/** | ||
* Returns an observable that spawns a process and emits events on stdout, stderr and exit. Output | ||
* is buffered by line. Unsubscribing before the observable completes will kill the process. This | ||
* function accepts the same options as `runCommand()`, and throws the same errors. | ||
* | ||
* Besides emitting multiple events, another difference with `runCommand()` is the ProcessExitErrors | ||
* thrown by `observeProcess()`. Whereas ProcessExitErrors thrown by `runCommand()` contain the | ||
* entirety of stdout and stderr, those thrown by `observeProcess()` contain a truncated amount of | ||
* stderr and no stdout. This is because `observeProcess()` is usually used with long-running | ||
* processes that may continue to produce output for a long while. The abbreviated stderr is | ||
* included to help with debugging. | ||
* | ||
* Example: | ||
* | ||
* ```js | ||
* const filesToTail: Observable<NuclideUri> = f(); | ||
* const subscription = filesToTail | ||
* // `switchMap()` means only one file will be tailed at a time. | ||
* .switchMap(path => observeProcess('tail', ['-f', path])) | ||
* .filter(event => event.kind === 'stdout') | ||
* .map(event => event.data) | ||
* .subscribe(line => { | ||
* console.log(line); | ||
* }); | ||
* ``` | ||
*/ | ||
// TODO(T17266325): Replace this in favor of `atom.whenShellEnvironmentLoaded()` when it lands | ||
function observeProcess(command, args, options) { | ||
@@ -599,2 +599,10 @@ return spawn(command, args, options).flatMap(proc => getOutputStream(proc, options)); | ||
// Exactly one of exitCode and signal will be non-null. | ||
// Killing a process will result in a null exitCode but a non-null signal. | ||
// In older versions of process.js, errors were emitted as messages instead of errors. This type | ||
// exists to support the transition, but no new usages should be added. | ||
// | ||
@@ -642,3 +650,3 @@ // Errors | ||
this.name = 'ProcessSystemError'; | ||
this.errno = err.errono; | ||
this.errno = err.errno; | ||
this.code = err.code; | ||
@@ -645,0 +653,0 @@ this.path = err.path; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3895
264233
47