From 4e58ffd645931c1d67af2626f65e9b4a475b259d Mon Sep 17 00:00:00 2001 From: Kirill Chernyshov Date: Mon, 7 Oct 2019 12:44:15 +0200 Subject: [PATCH] small fixes --- __tests__/tdeps.test.ts | 98 ++++++++++++++++++++--------------------- lib/leiningen.js | 2 +- lib/setup-clojure.js | 8 +++- lib/tdeps.js | 3 -- src/setup-clojure.ts | 12 ++--- 5 files changed, 63 insertions(+), 60 deletions(-) diff --git a/__tests__/tdeps.test.ts b/__tests__/tdeps.test.ts index 027f2f4..5201745 100644 --- a/__tests__/tdeps.test.ts +++ b/__tests__/tdeps.test.ts @@ -26,57 +26,57 @@ describe('tdeps tests', () => { } }, 100000); - it('Throws if invalid version', async () => { - let thrown = false; - try { - await tdeps.setup('1000'); - } catch { - thrown = true; - } - expect(thrown).toBe(true); - }); + it('Throws if invalid version', async () => { + let thrown = false; + try { + await tdeps.setup('1000'); + } catch { + thrown = true; + } + expect(thrown).toBe(true); + }); - it('Install clojure tools deps with normal version', async () => { - await tdeps.setup('1.10.1.469'); - const clojureDir = path.join( - toolDir, - 'ClojureToolsDeps', - '1.10.1-469', - os.arch() - ); + it('Install clojure tools deps with normal version', async () => { + await tdeps.setup('1.10.1.469'); + const clojureDir = path.join( + toolDir, + 'ClojureToolsDeps', + '1.10.1-469', + os.arch() + ); - expect(fs.existsSync(`${clojureDir}.complete`)).toBe(true); - expect(fs.existsSync(path.join(clojureDir, 'bin', 'clojure'))).toBe(true); - }, 100000); + expect(fs.existsSync(`${clojureDir}.complete`)).toBe(true); + expect(fs.existsSync(path.join(clojureDir, 'bin', 'clojure'))).toBe(true); + }, 100000); - it('Uses version of clojure tools-deps installed in cache', async () => { - const clojureDir: string = path.join( - toolDir, - 'ClojureToolsDeps', - '1.10.1-469', - os.arch() - ); - await io.mkdirP(clojureDir); - fs.writeFileSync(`${clojureDir}.complete`, 'hello'); - await tdeps.setup('1.10.1.469'); - return; - }); + it('Uses version of clojure tools-deps installed in cache', async () => { + const clojureDir: string = path.join( + toolDir, + 'ClojureToolsDeps', + '1.10.1-469', + os.arch() + ); + await io.mkdirP(clojureDir); + fs.writeFileSync(`${clojureDir}.complete`, 'hello'); + await tdeps.setup('1.10.1.469'); + return; + }); - it('Doesnt use version of clojure that was only partially installed in cache', async () => { - const clojureDir: string = path.join( - toolDir, - 'ClojureToolsDeps', - '1.10.1-469', - os.arch() - ); - await io.mkdirP(clojureDir); - let thrown = false; - try { - await tdeps.setup('1000'); - } catch { - thrown = true; - } - expect(thrown).toBe(true); - return; - }); + it('Doesnt use version of clojure that was only partially installed in cache', async () => { + const clojureDir: string = path.join( + toolDir, + 'ClojureToolsDeps', + '1.10.1-469', + os.arch() + ); + await io.mkdirP(clojureDir); + let thrown = false; + try { + await tdeps.setup('1000'); + } catch { + thrown = true; + } + expect(thrown).toBe(true); + return; + }); }); diff --git a/lib/leiningen.js b/lib/leiningen.js index d5ab8e2..01980f0 100644 --- a/lib/leiningen.js +++ b/lib/leiningen.js @@ -74,7 +74,7 @@ function installLeiningen(binScript, libFile, destinationFolder) { fs.chmodSync(path.join(binDir, `lein${IS_WINDOWS ? '.bat' : ''}`), '0755'); yield io.mv(lib, path.join(libDir, `leiningen-standalone.jar`)); if (IS_WINDOWS) { - yield readWriteAsync(path.join(binDir, 'lein.bat'), '!LEIN_HOME!\self-installs\leiningen-!LEIN_VERSION!-standalone.jar', '..\libexec\leiningen-standalone.jar'); + yield readWriteAsync(path.join(binDir, 'lein.bat'), '!LEIN_HOME!self-installsleiningen-!LEIN_VERSION!-standalone.jar', '..libexecleiningen-standalone.jar'); } else { yield readWriteAsync(path.join(binDir, 'lein'), '/usr/share/java/leiningen-$LEIN_VERSION-standalone.jar', '../libexec/leiningen-standalone.jar'); diff --git a/lib/setup-clojure.js b/lib/setup-clojure.js index bee6990..822a086 100644 --- a/lib/setup-clojure.js +++ b/lib/setup-clojure.js @@ -20,6 +20,7 @@ const core = __importStar(require("@actions/core")); const lein = __importStar(require("./leiningen")); const boot = __importStar(require("./boot")); const tdeps = __importStar(require("./tdeps")); +const IS_WINDOWS = process.platform === 'win32'; function run() { return __awaiter(this, void 0, void 0, function* () { try { @@ -33,7 +34,12 @@ function run() { boot.setup(Boot); } if (Tdeps) { - tdeps.setup(Tdeps); + if (IS_WINDOWS) { + throw new Error('Windows is not supported yet'); + } + else { + tdeps.setup(Tdeps); + } } if (!Boot && !Lein && !Tdeps) { throw new Error('You must specify at least one clojure tool.'); diff --git a/lib/tdeps.js b/lib/tdeps.js index 7943205..e28d48f 100644 --- a/lib/tdeps.js +++ b/lib/tdeps.js @@ -25,9 +25,6 @@ const os = __importStar(require("os")); const utils = __importStar(require("./utils")); let tempDirectory = process.env['RUNNER_TEMP'] || ''; const IS_WINDOWS = process.platform === 'win32'; -if (IS_WINDOWS) { - throw new Error('Windows is not supported yet.'); -} if (!tempDirectory) { let baseLocation; if (process.platform === 'darwin') { diff --git a/src/setup-clojure.ts b/src/setup-clojure.ts index eb44078..7eb4642 100644 --- a/src/setup-clojure.ts +++ b/src/setup-clojure.ts @@ -19,12 +19,12 @@ async function run() { boot.setup(Boot); } - if (Tdeps) { - if (IS_WINDOWS) { - throw new Error('Windows is not supported yet'); - } else { - tdeps.setup(Tdeps); - } + if (Tdeps) { + if (IS_WINDOWS) { + throw new Error('Windows is not supported yet'); + } else { + tdeps.setup(Tdeps); + } } if (!Boot && !Lein && !Tdeps) {