mirror of
https://github.com/oven-sh/setup-bun.git
synced 2025-02-23 18:50:10 +08:00
feat: use homedir from os
This commit is contained in:
parent
20a5153038
commit
9fb3c0c9e9
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -36,4 +36,4 @@ jobs:
|
|||||||
run: curl https://bun.sh/install | bash
|
run: curl https://bun.sh/install | bash
|
||||||
|
|
||||||
- name: Try bun
|
- name: Try bun
|
||||||
run: bun
|
run: /Users/runner/.bun/bin/bun
|
8
dist/utils/install.js
vendored
8
dist/utils/install.js
vendored
@ -2,13 +2,11 @@ import { cacheDir, downloadTool, extractZip, find } from '@actions/tool-cache';
|
|||||||
import { restoreCache, saveCache } from '@actions/cache';
|
import { restoreCache, saveCache } from '@actions/cache';
|
||||||
import { addPath, info } from '@actions/core';
|
import { addPath, info } from '@actions/core';
|
||||||
import getAsset from './getAsset.js';
|
import getAsset from './getAsset.js';
|
||||||
import getHomeDir from './getHomeDir.js';
|
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { homedir } from 'os';
|
import { homedir } from 'os';
|
||||||
export default async (release) => {
|
export default async (release) => {
|
||||||
console.log(getHomeDir(), homedir());
|
|
||||||
const asset = getAsset(release.assets);
|
const asset = getAsset(release.assets);
|
||||||
const path = join(getHomeDir(), '.bun', 'bin', asset.name);
|
const path = join(homedir(), '.bun', 'bin', asset.name);
|
||||||
const cache = find('bun', release.version) || await restoreCache([path], `bun-${process.platform}-${asset.name}-${release.version}`);
|
const cache = find('bun', release.version) || await restoreCache([path], `bun-${process.platform}-${asset.name}-${release.version}`);
|
||||||
if (cache) {
|
if (cache) {
|
||||||
info(`Using cached Bun installation from ${cache}.`);
|
info(`Using cached Bun installation from ${cache}.`);
|
||||||
@ -17,13 +15,13 @@ export default async (release) => {
|
|||||||
}
|
}
|
||||||
info(`Downloading Bun from ${asset.asset.browser_download_url}.`);
|
info(`Downloading Bun from ${asset.asset.browser_download_url}.`);
|
||||||
const zipPath = await downloadTool(asset.asset.browser_download_url);
|
const zipPath = await downloadTool(asset.asset.browser_download_url);
|
||||||
const extracted = await extractZip(zipPath, join(getHomeDir(), '.bun', 'bin'));
|
const extracted = await extractZip(zipPath, join(homedir(), '.bun', 'bin'));
|
||||||
const newCache = await cacheDir(extracted, 'bun', release.version);
|
const newCache = await cacheDir(extracted, 'bun', release.version);
|
||||||
await saveCache([
|
await saveCache([
|
||||||
join(extracted, asset.name)
|
join(extracted, asset.name)
|
||||||
], `bun-${process.platform}-${asset.name}-${release.version}`);
|
], `bun-${process.platform}-${asset.name}-${release.version}`);
|
||||||
info(`Cached Bun to ${newCache}.`);
|
info(`Cached Bun to ${newCache}.`);
|
||||||
addPath(newCache);
|
addPath(newCache);
|
||||||
const bunPath = join(getHomeDir(), '.bun', 'bin', asset.name);
|
const bunPath = join(homedir(), '.bun', 'bin', asset.name);
|
||||||
addPath(bunPath);
|
addPath(bunPath);
|
||||||
};
|
};
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
export default () => {
|
|
||||||
return process.env[process.platform == 'win32' ? 'USERPROFILE' : 'HOME'];
|
|
||||||
};
|
|
@ -3,14 +3,12 @@ import { cacheDir, downloadTool, extractZip, find } from '@actions/tool-cache';
|
|||||||
import { restoreCache, saveCache } from '@actions/cache';
|
import { restoreCache, saveCache } from '@actions/cache';
|
||||||
import { addPath, info } from '@actions/core';
|
import { addPath, info } from '@actions/core';
|
||||||
import getAsset from './getAsset.js';
|
import getAsset from './getAsset.js';
|
||||||
import getHomeDir from './getHomeDir.js';
|
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { homedir } from 'os';
|
import { homedir } from 'os';
|
||||||
|
|
||||||
export default async(release: Release) => {
|
export default async(release: Release) => {
|
||||||
console.log(getHomeDir(), homedir());
|
|
||||||
const asset = getAsset(release.assets);
|
const asset = getAsset(release.assets);
|
||||||
const path = join(getHomeDir(), '.bun', 'bin', asset.name);
|
const path = join(homedir(), '.bun', 'bin', asset.name);
|
||||||
const cache = find('bun', release.version) || await restoreCache([path], `bun-${process.platform}-${asset.name}-${release.version}`);
|
const cache = find('bun', release.version) || await restoreCache([path], `bun-${process.platform}-${asset.name}-${release.version}`);
|
||||||
if (cache) {
|
if (cache) {
|
||||||
info(`Using cached Bun installation from ${cache}.`);
|
info(`Using cached Bun installation from ${cache}.`);
|
||||||
@ -21,7 +19,7 @@ export default async(release: Release) => {
|
|||||||
info(`Downloading Bun from ${asset.asset.browser_download_url}.`);
|
info(`Downloading Bun from ${asset.asset.browser_download_url}.`);
|
||||||
|
|
||||||
const zipPath = await downloadTool(asset.asset.browser_download_url);
|
const zipPath = await downloadTool(asset.asset.browser_download_url);
|
||||||
const extracted = await extractZip(zipPath, join(getHomeDir(), '.bun', 'bin'));
|
const extracted = await extractZip(zipPath, join(homedir(), '.bun', 'bin'));
|
||||||
|
|
||||||
const newCache = await cacheDir(
|
const newCache = await cacheDir(
|
||||||
extracted,
|
extracted,
|
||||||
@ -35,6 +33,6 @@ export default async(release: Release) => {
|
|||||||
info(`Cached Bun to ${newCache}.`);
|
info(`Cached Bun to ${newCache}.`);
|
||||||
addPath(newCache);
|
addPath(newCache);
|
||||||
|
|
||||||
const bunPath = join(getHomeDir(), '.bun', 'bin', asset.name);
|
const bunPath = join(homedir(), '.bun', 'bin', asset.name);
|
||||||
addPath(bunPath);
|
addPath(bunPath);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user