Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set LEIN_JAR #104

Merged
merged 4 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,6 @@ jobs:
run: |
lein version

- name: lein pwsh
shell: pwsh
run: |
lein version

- name: lein cmd
shell: cmd
run: |
Expand Down Expand Up @@ -312,7 +307,7 @@ jobs:
uses: ./
with:
cli: 1.11.1.1149
lein: 2.9.1
lein: 2.11.0
boot: 2.8.3
bb: 0.8.157
clj-kondo: 2022.06.22
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
java-version: '8'

- name: Install clojure tools
uses: DeLaGuardo/setup-clojure@12.3
uses: DeLaGuardo/setup-clojure@12.4
with:
# Install just one or all simultaneously
# The value must indicate a particular version of the tool, or use 'latest'
Expand Down
30 changes: 24 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1071,9 +1071,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.mkdir = exports.cp = exports.writeFile = exports.readFile = exports.chmod = exports.stat = void 0;
exports.readdir = exports.mkdir = exports.cp = exports.writeFile = exports.readFile = exports.chmod = exports.stat = void 0;
const fs_1 = __importDefault(__nccwpck_require__(7147));
_a = fs_1.default.promises, exports.stat = _a.stat, exports.chmod = _a.chmod, exports.readFile = _a.readFile, exports.writeFile = _a.writeFile, exports.cp = _a.cp, exports.mkdir = _a.mkdir;
_a = fs_1.default.promises, exports.stat = _a.stat, exports.chmod = _a.chmod, exports.readFile = _a.readFile, exports.writeFile = _a.writeFile, exports.cp = _a.cp, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir;


/***/ }),
Expand Down Expand Up @@ -1148,6 +1148,10 @@ function setup(version, githubAuth) {
core.debug(`Leiningen installed to ${leiningenDir}`);
toolPath = yield tc.cacheDir(leiningenDir, exports.identifier, utils.getCacheVersionString(version));
}
const leiningenJarPath = yield leiningenJar(toolPath);
if (leiningenJarPath !== null) {
core.exportVariable('LEIN_JAR', leiningenJarPath);
}
core.exportVariable('LEIN_HOME', toolPath);
core.addPath(path.join(toolPath, 'bin'));
});
Expand Down Expand Up @@ -1175,8 +1179,9 @@ function installLeiningen(binScripts, destinationFolder) {
const version_cmd = isWindows
? 'powershell .\\lein.ps1 self-install'
: './lein version';
const toolDir = path.join(destinationFolder, 'leiningen');
const env = {
LEIN_HOME: path.join(destinationFolder, 'leiningen')
LEIN_HOME: toolDir
};
if (process.env['PATH']) {
env['PATH'] = process.env['PATH'];
Expand All @@ -1185,10 +1190,23 @@ function installLeiningen(binScripts, destinationFolder) {
env['JAVA_CMD'] = process.env['JAVA_CMD'];
}
yield exec.exec(version_cmd, [], {
cwd: path.join(destinationFolder, 'leiningen', 'bin'),
cwd: path.join(toolDir, 'bin'),
env
});
return path.join(destinationFolder, 'leiningen');
return toolDir;
});
}
function leiningenJar(toolPath) {
return __awaiter(this, void 0, void 0, function* () {
const files = yield fs.readdir(path.join(toolPath, 'self-installs'));
if (files) {
for (const file of files) {
if (file.endsWith('.jar')) {
return path.join(toolPath, 'self-installs', file);
}
}
}
return null;
});
}

Expand Down Expand Up @@ -1309,7 +1327,7 @@ exports.isMacOS = isMacOS;

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.VERSION = void 0;
exports.VERSION = '12-3';
exports.VERSION = '12-4';


/***/ }),
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/fs.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import fs from 'fs'

export const {stat, chmod, readFile, writeFile, cp, mkdir} = fs.promises
export const {stat, chmod, readFile, writeFile, cp, mkdir, readdir} =
fs.promises
27 changes: 24 additions & 3 deletions src/leiningen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ export async function setup(
)
}

const leiningenJarPath = await leiningenJar(toolPath)

if (leiningenJarPath !== null) {
core.exportVariable('LEIN_JAR', leiningenJarPath)
}

core.exportVariable('LEIN_HOME', toolPath)
core.addPath(path.join(toolPath, 'bin'))
}
Expand Down Expand Up @@ -96,8 +102,10 @@ async function installLeiningen(
? 'powershell .\\lein.ps1 self-install'
: './lein version'

const toolDir = path.join(destinationFolder, 'leiningen')

const env: {[key: string]: string} = {
LEIN_HOME: path.join(destinationFolder, 'leiningen')
LEIN_HOME: toolDir
}

if (process.env['PATH']) {
Expand All @@ -108,9 +116,22 @@ async function installLeiningen(
}

await exec.exec(version_cmd, [], {
cwd: path.join(destinationFolder, 'leiningen', 'bin'),
cwd: path.join(toolDir, 'bin'),
env
})

return path.join(destinationFolder, 'leiningen')
return toolDir
}

async function leiningenJar(toolPath: string): Promise<string | null> {
const files = await fs.readdir(path.join(toolPath, 'self-installs'))
if (files) {
for (const file of files) {
if (file.endsWith('.jar')) {
return path.join(toolPath, 'self-installs', file)
}
}
}

return null
}
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '12-3'
export const VERSION = '12-4'
Loading