Skip to content

Commit

Permalink
Merge pull request #1781 from milaboratory/do-not-die-without-archive…
Browse files Browse the repository at this point in the history
…-in-ci

feat: do not die in CI when ARCHIVE_PATH is empty
  • Loading branch information
DenKoren authored Sep 6, 2024
2 parents 2254b57 + dc8a41b commit 3956c95
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions pl-pkg/scripts/unpack-ci.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
#!/usr/bin/env node

const fs = require('fs');
const path = require('path');
const fs = require("fs");
const path = require("path");

const scriptDir = __dirname;
const packageRoot = path.resolve(scriptDir, "../")
const dstRoot = path.join(packageRoot, 'dld');
const dstDataDir = path.join(dstRoot, 'mixcr');

if (!process.env.CI) {
log("Not a CI run. install-ci.js was skipped")
process.exit(0)
}
const packageRoot = path.resolve(scriptDir, "../");
const dstRoot = path.join(packageRoot, "dld");
const dstDataDir = path.join(dstRoot, "mixcr");

function log(message) {
console.log(message);
}

if (!process.env.CI) {
process.exit(0);
}

const ARCHIVE_PATH = process.env.ARCHIVE_PATH;
if (!ARCHIVE_PATH) {
throw new Error("ARCHIVE_PATH environment variable is required.");
log(
"To unpack existing archive after installation, provide 'ARCHIVE_PATH'" +
"environment variable with path to the mixcr archive before running 'npm ci' or 'npm install'"
);
process.exit(0)
}

function isDir(target) {
Expand Down Expand Up @@ -60,8 +63,8 @@ if (fs.existsSync(dstDataDir)) {
log(`Creating clean data dir: ${dstDataDir}`);
fs.mkdirSync(dstDataDir, { recursive: true });

const unzipper = require('unzipper');
const unzipper = require("unzipper");

fs.createReadStream(archivePath)
.pipe(unzipper.Extract({ path: dstDataDir }))
.on('close', () => log(`Extraction complete to '${dstDataDir}'`));
.on("close", () => log(`Extraction complete to '${dstDataDir}'`));

0 comments on commit 3956c95

Please sign in to comment.