Move main script

parent 9f820ed2
module.exports = {
extends: 'google',
parserOptions: {
ecmaVersion: 8,
sourceType: 'module'
}
};
......@@ -15,5 +15,11 @@
"gulp": "^4.0.0",
"gulp-babel": "^8.0.0",
"pump": "^3.0.0"
},
"scripts": {
"start": "node dist/cli.js"
},
"bin": {
"icloud-drive-fs": "dist/cli.js"
}
}
#!/usr/bin/env node
import path from 'path';
import yargs from 'yargs';
import fuse from './fuse';
import iCloudService from '../../api';
import mount from '..';
// const apple_id = process.argv[2];
const mount_path = yargs.argv.mount || process.platform !== 'win32' ? path.resolve(__dirname, '..', 'mount') : 'M:\\';
(async () => {
const icloud = new iCloudService('apple-id', 'password');
await icloud.authenticate();
await mount(icloud, mount_path);
console.log('Filesystem mounted at ' + mount_path);
process.on('SIGINT', async () => {
try {
await fuse.unmount(mount_path);
console.log('Filesystem at ' + mount_path + ' unmounted');
} catch (err) {
console.log('Filesystem at ' + mount_path + ' not unmounted', err);
process.exit(1);
}
});
})();
import iCloudService from '../..';
import yargs from 'yargs';
import path from 'path';
import fuse from './fuse';
const mount_path = yargs.argv.mount || process.platform !== 'win32' ? path.resolve(__dirname, '..', 'mount') : 'M:\\';
function parsePath(path) {
// What?
if (path.substr(0, 1) !== '/') path = '/';
......@@ -41,10 +37,7 @@ function parsePath(path) {
};
}
(async () => {
const icloud = new iCloudService('apple-id', 'password');
await icloud.authenticate();
export default async function mount(icloud, mount_path, mount_options) {
const root = await icloud.drive['com.apple.CloudDocs'];
const libraries = await icloud.drive.getAppLibraries();
......@@ -175,22 +168,10 @@ function parsePath(path) {
buffer.write(str);
return str.length;
}
}, [
}, mount_options || [
'force',
'noappledouble',
'volname=iCloud Drive',
'fsname=icloud#' + icloud.apple_id
]);
console.log('Filesystem mounted at ' + mount_path);
process.on('SIGINT', async () => {
try {
await fuse.unmount(mount_path);
console.log('Filesystem at ' + mount_path + ' unmounted');
} catch (err) {
console.log('Filesystem at ' + mount_path + ' not unmounted', err);
process.exit(1);
}
});
})();
}
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