Skip to content

Commit

Permalink
feat: update mac already clean
Browse files Browse the repository at this point in the history
  • Loading branch information
akitaSummer committed Mar 5, 2024
1 parent 5775281 commit 2c13f8c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 18 deletions.
26 changes: 14 additions & 12 deletions packages/cli/lib/deamon.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,23 @@ root:
};

const initDeamon = async () => {
const isRunning = await checkDeamonAlive();
if (isRunning) {
console.info('[rapid] rapid daemon is running already.');
return;
}
await fs.mkdir(deamonDir, { recursive: true });

await fs.mkdir(nydusdMnt, { recursive: true });

try {
const rapidVersion = require(path.join(__dirname, '../package.json')).version;
const deamonVersion = require(path.join(deamonDir, 'package.json')).version;
const rapidVersion = require(path.join(__dirname, '../package.json')).deamonVersion;
const deamonVersion = require(path.join(deamonDir, './package.json')).deamonVersion;
console.log(rapidVersion, deamonVersion);
if (rapidVersion !== deamonVersion) {
throw Error('[rapid] rapid and deamon version not match');
const err = '[rapid] rapid and deamon version not match';
console.info(err);
throw Error(err);
}
const isRunning = await checkDeamonAlive();
if (isRunning) {
console.info('[rapid] rapid daemon is running already.');
return;
}
await fs.mkdir(deamonDir, { recursive: true });

await fs.mkdir(nydusdMnt, { recursive: true });
await fs.stat(destinationFilePath);
} catch (e) {
await registerDeamon();
Expand Down
15 changes: 13 additions & 2 deletions packages/cli/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,23 @@ exports.install = async options => {
const { baseDir, tarIndex, nodeModulesDir } = await util.getWorkdir(options.cwd, pkgPath);

const mountedInfo = currentMountInfo.find(item => item.mountPoint === nodeModulesDir);
let isMounted = false;

if (os.type() === 'Darwin') {
try {
await fs.stat(nodeModulesDir);
isMounted = true;
} catch (e) {
console.log(e);
}
await fs.rm(nodeModulesDir, { recursive: true, force: true });
}

if (mountedInfo) {
if (mountedInfo || isMounted) {
console.time(`[rapid] ${nodeModulesDir} already mounted, try to clean`);
await exports.clean({
nydusMode: options.nydusMode,
cwd: mountedInfo.mountPoint,
cwd: options.cwd,
pkg: options.pkg,
force: true,
daemon: options.daemon,
Expand Down
4 changes: 1 addition & 3 deletions packages/cli/lib/nydusd/fuse_mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ async function mountNydus(cwd, pkg, config) {
// 需要串行 mount,并发创建时 nydusd 会出现问题
for (const pkgPath of allPkgs) {
const { dirname, bootstrap, nodeModulesDir } = await getWorkdir(cwd, pkgPath);
if (os.type() === 'Darwin') {
await fs.rm(nodeModulesDir, { recursive: true, force: true });
}

const nydusdConfig = await nydusdApi.mount(`/${dirname}`, cwd, bootstrap);
mounts.push({
mountpoint: `${dirname}`,
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@
"rapid",
"npm"
],
"author": "gemwuu <gemwuu@163.com> (https://github.com/gemwuu)"
"author": "gemwuu <gemwuu@163.com> (https://github.com/gemwuu)",
"deamonVersion": "0.0.1"
}

0 comments on commit 2c13f8c

Please sign in to comment.