Files
pnpm/packages/mount-modules/src/cli.ts
Zoltan Kochan 0d68aa002e style: fix
2021-03-17 17:27:00 +02:00

26 lines
868 B
TypeScript

import { promises as fs } from 'fs'
import path from 'path'
import getStorePath from '@pnpm/store-path'
import Fuse from 'fuse-native'
import createFuseHandlers from './createFuseHandlers'
(async () => { /* eslint-disable-line */
const mnt = path.join(process.cwd(), 'node_modules')
await fs.mkdir(mnt, { recursive: true })
const cafsDir = path.join(await getStorePath(process.cwd()), 'files')
const fuse = new Fuse(mnt, await createFuseHandlers(process.cwd(), cafsDir), { debug: true })
fuse.mount(function (err?: Error) {
if (err != null) console.error(err)
})
process.once('SIGINT', function () {
fuse.unmount((err?: Error) => {
if (err != null) {
console.log(`filesystem at ${fuse.mnt as string} not unmounted`, err)
} else {
console.log(`filesystem at ${fuse.mnt as string} unmounted`)
}
})
})
})()