function extractInTmpDir()

in core/nodejsActionBase/runner.js [153:182]


function extractInTmpDir(archiveFileContents) {
    const mkTempCmd = "mktemp -d XXXXXXXX";
    return exec(mkTempCmd).then(tmpDir => {
        return new Promise((resolve, reject) => {
            ext = detectFileType(archiveFileContents)
            if (ext == 'unsupported'){
                reject("There was an error Detecting the File type");
            }
            const archiveFile = path.join(tmpDir, "action."+ ext);
            fs.writeFile(archiveFile, archiveFileContents, "base64", err => {
                if (!err) resolve(archiveFile);
                else reject("There was an error reading the action archive.");
            });
        });
    }).then(archiveFile => {
        return exec(mkTempCmd).then(tmpDir => {
            if (ext === 'zip') {
                return exec("unzip -qq " + archiveFile + " -d " + tmpDir)
                .then(res => path.resolve(tmpDir))
                .catch(error => Promise.reject("There was an error uncompressing the action Zip archive."));
            } else if (ext === 'tar.gz') {
                return exec("tar -xzf " + archiveFile + " -C " + tmpDir + " > /dev/null")
                .then(res => path.resolve(tmpDir))
                .catch(error => Promise.reject("There was an error uncompressing the action Tar GZ archive."));
            } else {
                  return Promise.reject("There was an error uncompressing the action archive. file ext did not Match");
            }
        });
    });
}