-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: auto install fuse-t * feat: add INSTALL_FUSE_T env
- Loading branch information
Showing
6 changed files
with
57 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const fs = require('node:fs/promises'); | ||
const fsSync = require('node:fs'); | ||
const crypto = require('node:crypto'); | ||
const path = require('node:path'); | ||
const urllib = require('urllib'); | ||
const execa = require('execa'); | ||
const inquirer = require('inquirer'); | ||
|
||
const FUSE_T_INSTALL_PATH = '/usr/local/bin/go-nfsv4'; | ||
const FUSE_T_VERSION = '1.0.28'; | ||
const FUSE_T_DOWNLOAD_URL = `https://registry.npmmirror.com/-/binary/fuse-t/${FUSE_T_VERSION}/fuse-t-macos-installer-${FUSE_T_VERSION}.pkg`; | ||
|
||
exports.checkFuseT = async function checkFuseT() { | ||
try { | ||
await fs.stat(FUSE_T_INSTALL_PATH); | ||
return true; | ||
} catch { | ||
return false; | ||
} | ||
}; | ||
|
||
exports.installFuseT = async function installFuseT() { | ||
const tmpPath = path.join('/tmp', `${crypto.randomUUID()}.pkg`); | ||
await urllib.request(FUSE_T_DOWNLOAD_URL, { | ||
method: 'GET', | ||
writeStream: fsSync.createWriteStream(tmpPath), | ||
followRedirect: true, | ||
}); | ||
await execa.command(`sudo installer -pkg ${tmpPath} -target /`); | ||
}; | ||
|
||
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', | ||
message: 'Do you want install fuse-t?', | ||
default: true, | ||
}]); | ||
return answers.installFuseT === true; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters