Skip to content

Commit

Permalink
feat: add INSTALL_FUSE_T env
Browse files Browse the repository at this point in the history
  • Loading branch information
killagu committed Oct 25, 2023
1 parent 6d38c78 commit aed2bfa
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 23 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,6 @@ jobs:
- name: Change directory ownership
run: chown -R $(id -un):$(id -gn) .

- name: Install macfuse
run: |
wget https://github.com/macos-fuse-t/fuse-t/releases/download/1.0.24/fuse-t-macos-installer-1.0.24.pkg
sudo installer -pkg fuse-t-macos-installer-1.0.24.pkg -target /
- name: Rust Cache
uses: actions/cache@v3
with:
Expand All @@ -205,6 +200,6 @@ jobs:
CARGO_BUILD_TARGET=x86_64-apple-darwin BUILD_OS=macos BUILD_ARCH=amd64 npm run init:ci
- name: Run CI
run: npm run test:integration
run: INSTALL_FUSE_T=true npm run test:integration
env:
NODE_OPTIONS: --max_old_space_size=6144
6 changes: 6 additions & 0 deletions packages/cli/bin/rapid.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const yargs = require('yargs');
const { NpmFsMode, NYDUS_TYPE } = require('../lib/constants.js');
const util = require('../lib/util');
const path = require('node:path');
const fuse_t = require('../lib/fuse_t');

yargs
.command({
Expand All @@ -31,6 +32,11 @@ yargs
const cwd = process.cwd();
const pkgRes = await util.readPkgJSON();
const pkg = pkgRes?.pkg || {};
if (!(await fuse_t.checkFuseT())) {
if (await fuse_t.confirmInstallFuseT()) {
await fuse_t.installFuseT();
}
}

await util.shouldFuseSupport();
await install({
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/lib/fuse_t.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ exports.installFuseT = async function installFuseT() {
};

exports.confirmInstallFuseT = async function confirmInstallFuseT() {
if (process.env.INSTALL_FUSE_T === 'true') return true;
if (!process.stdout.isTTY) return false;
const answers = await inquirer.prompt([{
type: 'confirm',
name: 'installFuseT',
Expand Down
19 changes: 2 additions & 17 deletions packages/cli/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const {
nydusdBootstrapFile,
nydusdMnt,
} = require('./constants');
let confirmed = false;
const fuse_t = require('./fuse_t');

// node_modules/a -> a
// node_mdoules/@scope/b -> @scope/b
Expand Down Expand Up @@ -106,22 +106,7 @@ async function shouldFuseSupport() {

if (os.type() === 'Darwin') {
const fuseTInstalled = await fuse_t.checkFuseT();
if (fuseTInstalled) {
return;
}
if (confirmed) {
throw new NotSupportedError('install fuse-t first.');
}
const confirmInstallFuseT = await fuse_t.confirmInstallFuseT();
confirmed = true;
if (!confirmInstallFuseT) {
throw new NotSupportedError('install fuse-t first.');
}
try {
await fuse_t.installFuseT();
} catch (error) {
error.message = '[rapid] install fuse-t failed: ' + error.message;
console.warn(error);
if (!fuseTInstalled) {
throw new NotSupportedError('install fuse-t first.');
}
}
Expand Down

0 comments on commit aed2bfa

Please sign in to comment.