text: /*!
  GPII Process Reporter processes bridge -- gpii.processes.
  
  Copyright 2016-2017 Inclusive Design Research Centre, OCAD University
  
  Licensed under the New BSD license. You may not use this file except in
  compliance with this License.
  
  You may obtain a copy of the License at
  https://github.com/gpii/universal/LICENSE.txt
  */
  
  /*global require */
  
  "use strict";
  
  var path = require("path"),
      // This conditional require is to run the electron version of edge.js
      // when this code runs on electron (gpii-app).
      edge = process.versions.electron ? require("electron-edge-js") : require("edge-js"),
      stringArgv = require("string-argv"),
      fluid = require("gpii-universal");
  
  var gpii = fluid.registerNamespace("gpii");
  
  var dotNetProcesses = edge.func({
      source: path.join(__dirname, "dotNetProcesses.csx"),
      references: ["System.Management.dll"]
  });
  
  fluid.defaults("gpii.processes.windows", {
      gradeNames: ["gpii.processes"],
      invokers: {
          getProcessList: {
              funcName: "gpii.processes.windows.getProcessList",
              args: ["{arguments}.0"]
                     // process name or id, optional.
          }
      }
  });
  
  /**
   * Return a list of processes -- a snapshot of the current processes.  If the
   * process name or process id is passed, then the return value will be limited
   * to only processes with that name or the process with that pid.
   *
   * @param {String} or {Number} Optional.  Specify a process to find via a name
   *                                        (string), or a process id (number).
   */
  gpii.processes.windows.getProcessList = function (processIdentifier) {
      var procInfos = dotNetProcesses(processIdentifier, true);
  
      // Loop to convert the command line to an argv[].
      fluid.each(procInfos, function (aProcInfo) {
          aProcInfo.argv = stringArgv(aProcInfo.commandLine);
          delete aProcInfo.commandLine;
  
          // In some cases the first argument is just the command, e.g., "Notepad".
          // In others, it is the full path and may include the ".exe"
          // extension.  Normalize it to always be the full path.
          aProcInfo.argv[0] = aProcInfo.fullPath;
      });
      return procInfos;
  };
  