[gnome-ostree/wip/gjs-round2] procutil: Clean up context creation a bit



commit 32761f0c15f920fae7445913aba5e3f07a1bda3d
Author: Colin Walters <walters verbum org>
Date:   Sat Dec 15 06:51:04 2012 -0500

    procutil: Clean up context creation a bit

 src/ostbuild/js/procutil.js |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)
---
diff --git a/src/ostbuild/js/procutil.js b/src/ostbuild/js/procutil.js
index b58372d..6964ff2 100644
--- a/src/ostbuild/js/procutil.js
+++ b/src/ostbuild/js/procutil.js
@@ -12,7 +12,8 @@ function objectToEnvironment(o) {
     return r;
 }
 
-function _setContextFromParams(context, params) {
+function _newContext(argv, params) {
+    let context = new GSystem.SubprocessContext({argv: argv});
     params = Params.parse(params, {cwd: null,
 				   env: null,
 				   stderr: null });
@@ -26,6 +27,7 @@ function _setContextFromParams(context, params) {
 
     if (params.stderr != null)
 	context.set_stderr_disposition(params.stderr);
+    return context;
 }
 
 function _wait_sync_check_internal(proc, cancellable) {
@@ -43,20 +45,15 @@ function _wait_sync_check_internal(proc, cancellable) {
     }
 }
 
-function runSync(args, cancellable, params) {
-    let context = new GSystem.SubprocessContext({argv: args});
-    _setContextFromParams(context, params);
+function runSync(argv, cancellable, params) {
+    let context = _newContext(argv, params);
     let proc = new GSystem.Subprocess({context: context});
     proc.init(cancellable);
     _wait_sync_check_internal(proc, cancellable);
 }
 
-function _runSyncGetOutputInternal(args, cancellable, params, splitLines) {
-    params = Params.parse(params, {cwd: null,
-				   env: null,
-				   stderr: null});
-    let context = new GSystem.SubprocessContext({argv: args});
-    _setContextFromParams(context, params);
+function _runSyncGetOutputInternal(argv, cancellable, params, splitLines) {
+    let context = _newContext(argv, params);
     context.set_stdout_disposition(GSystem.SubprocessStreamDisposition.PIPE);
     context.set_stderr_disposition(GSystem.SubprocessStreamDisposition.INHERIT);
     let proc = new GSystem.Subprocess({context: context});



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]