How to use the test function from shelljs

Find comprehensive JavaScript shelljs.test code examples handpicked from public code repositorys.

652
653
654
655
656
657
658
659
660
661

const DOCS_RULES_DIR = path.join(DOCS_SRC_DIR, "rules");
const RULE_VERSIONS_FILE = path.join(DOCS_SRC_DIR, "_data/rule_versions.json");

// Set up rule version information
let versions = test("-f", RULE_VERSIONS_FILE) ? JSON.parse(cat(RULE_VERSIONS_FILE)) : {};

if (!versions.added) {
    versions = {
        added: versions,
fork icon0
star icon0
watch icon1

+ 29 other calls in file

611
612
613
614
615
616
617
618
619
620
        htmlFullPath = fullPath.replace(".md", ".html");

    if (test("-f", fullPath)) {
        rm("-rf", fullPath);

        if (filePath.indexOf(".md") >= 0 && test("-f", htmlFullPath)) {
            rm("-rf", htmlFullPath);
        }
    }
});
fork icon0
star icon0
watch icon0

+ 25 other calls in file

73
74
75
76
77
78
79
80
81
82
83
    shellAssert();
}
exports.rm = rm;


var test = function (options, p) {
    var result = shell.test(options, p);
    shellAssert();
    return result;
}
exports.test = test;
fork icon0
star icon0
watch icon0