All files / root/gpii/node_modules/processReporter processReporter.js

100% Statements 15/15
100% Branches 4/4
100% Functions 1/1
100% Lines 15/15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43                            2x 2x 2x   2x   2x 2x                 2x 2x 2x 2x 2x 1x   2x 1x   2x    
/**
 * GPII Process Reporter Bridge (Linux -- GLiBTop).
 *
 * Copyright 2016-2017 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
 */
 
"use strict";
 
var fluid = require("universal");
var gpii = fluid.registerNamespace("gpii");
require("./processesBridge.js");
 
var processesBridge = gpii.processes.windows();
 
fluid.registerNamespace("gpii.processReporter");
fluid.defaults("gpii.processReporter.find", {
    gradeNames: "fluid.function",
    argumentMap: {
        command: 0
    }
});
 
// Search for the process using its command name.  Returns a boolean indicating
// if the process is running (and if the setting is set).
gpii.processReporter.find = function (commandName) {
    var running = false;
    var theProcess = null;
    var procInfos = processesBridge.findSolutionsByCommands([commandName]);
    if (procInfos.length > 0) {
        theProcess = procInfos[0];
    }
    if (theProcess !== null) {
        running = processesBridge.isRunning(theProcess.state);
    }
    return running;
};