Create the mount point if it doesn’t exist

parent a2cb95d7
node_modules
dist
mount
mount-2
......@@ -27,8 +27,9 @@ npm install -g icloud-drive-fs
```
git clone https://gitlab.fancy.org.uk/samuel/icloud-drive-fs
cd icloud-drive-fs
npm link
npx gulp build # or npx gulp watch
node dist/cli.js apple-id --mount /path/to/mount
```
Usage
......
......@@ -19,6 +19,7 @@
"@samuelthomas2774/icloud-api": "^0.1.4",
"fuse-bindings": "^2.11.2",
"keytar": "^4.2.1",
"mkdirp": "^0.5.1",
"yargs": "^12.0.2"
},
"devDependencies": {
......
......@@ -5,6 +5,7 @@ import readline from 'readline';
import yargs from 'yargs';
import fuse from './fuse';
import keytar from 'keytar';
import _mkdirp from 'mkdirp';
import iCloudService from '@samuelthomas2774/icloud-api';
import mount from '..';
......@@ -13,6 +14,12 @@ const apple_id = process.argv[2];
const mount_path = yargs.argv.mount ? path.resolve(process.cwd(), yargs.argv.mount) :
process.platform !== 'win32' ? path.resolve(__dirname, '..', 'mount') : 'M:\\';
function mkdirp(dir, opts) {
return new Promise((resolve, reject) => {
_mkdirp(dir, opts, (err, made) => err ? reject(err) : resolve(made));
});
}
function prompt(message) {
return new Promise((resolve, reject) => {
const password_readline = readline.createInterface(process.stdin, process.stdout);
......@@ -52,6 +59,10 @@ process.on('SIGINT', () => process.stdout.write('\u001B[28m'));
throw new Error('Account requires two step authentication');
}
const created_mount_path = await mkdirp(mount_path);
if (created_mount_path) console.log('Created ' + created_mount_path);
console.log('Mounting at ' + mount_path);
await mount(icloud, mount_path);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment