2017-06-25 18:30:44 +02:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
2017-08-03 19:48:14 +02:00
|
|
|
// Loading time: 20170803: 1.5s with no commands
|
|
|
|
|
2017-06-22 23:52:27 +02:00
|
|
|
require('source-map-support').install();
|
|
|
|
require('babel-plugin-transform-runtime');
|
|
|
|
|
2017-07-10 22:03:46 +02:00
|
|
|
import { app } from './app.js';
|
2017-06-24 20:06:28 +02:00
|
|
|
import { BaseModel } from 'lib/base-model.js';
|
|
|
|
import { Folder } from 'lib/models/folder.js';
|
2017-07-02 14:02:07 +02:00
|
|
|
import { Resource } from 'lib/models/resource.js';
|
2017-06-25 09:35:59 +02:00
|
|
|
import { BaseItem } from 'lib/models/base-item.js';
|
2017-06-24 20:06:28 +02:00
|
|
|
import { Note } from 'lib/models/note.js';
|
2017-07-03 20:58:01 +02:00
|
|
|
import { Tag } from 'lib/models/tag.js';
|
2017-07-06 21:48:17 +02:00
|
|
|
import { NoteTag } from 'lib/models/note-tag.js';
|
2017-06-24 20:06:28 +02:00
|
|
|
import { Setting } from 'lib/models/setting.js';
|
|
|
|
import { Logger } from 'lib/logger.js';
|
2017-07-05 23:52:31 +02:00
|
|
|
import { FsDriverNode } from './fs-driver-node.js';
|
2017-07-10 20:09:58 +02:00
|
|
|
import { shimInit } from 'lib/shim-init-node.js';
|
2017-06-24 20:06:28 +02:00
|
|
|
import { _ } from 'lib/locale.js';
|
2017-06-22 23:52:27 +02:00
|
|
|
|
2017-06-23 23:32:24 +02:00
|
|
|
process.on('unhandledRejection', (reason, p) => {
|
2017-06-26 00:20:07 +02:00
|
|
|
console.error('Unhandled promise rejection', p, 'reason:', reason);
|
2017-06-23 23:32:24 +02:00
|
|
|
});
|
|
|
|
|
2017-07-05 23:52:31 +02:00
|
|
|
const fsDriver = new FsDriverNode();
|
|
|
|
Logger.fsDriver_ = fsDriver;
|
|
|
|
Resource.fsDriver_ = fsDriver;
|
|
|
|
|
2017-07-10 22:03:46 +02:00
|
|
|
// That's not good, but it's to avoid circular dependency issues
|
|
|
|
// in the BaseItem class.
|
|
|
|
BaseItem.loadClass('Note', Note);
|
|
|
|
BaseItem.loadClass('Folder', Folder);
|
|
|
|
BaseItem.loadClass('Resource', Resource);
|
|
|
|
BaseItem.loadClass('Tag', Tag);
|
|
|
|
BaseItem.loadClass('NoteTag', NoteTag);
|
|
|
|
|
2017-06-29 22:52:52 +02:00
|
|
|
Setting.setConstant('appId', 'net.cozic.joplin-cli');
|
2017-07-07 00:15:31 +02:00
|
|
|
Setting.setConstant('appType', 'cli');
|
2017-06-29 22:52:52 +02:00
|
|
|
|
2017-07-10 22:03:46 +02:00
|
|
|
shimInit();
|
2017-06-22 23:52:27 +02:00
|
|
|
|
2017-08-04 18:50:12 +02:00
|
|
|
const application = app();
|
|
|
|
|
|
|
|
if (process.platform === "win32") {
|
|
|
|
var rl = require("readline").createInterface({
|
|
|
|
input: process.stdin,
|
|
|
|
output: process.stdout
|
|
|
|
});
|
|
|
|
|
|
|
|
rl.on("SIGINT", function () {
|
|
|
|
process.emit("SIGINT");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
process.on("SIGINT", async function() {
|
|
|
|
console.info(_('Received %s', 'SIGINT'));
|
|
|
|
await application.cancelCurrentCommand();
|
|
|
|
});
|
|
|
|
|
|
|
|
application.start().catch((error) => {
|
2017-07-18 20:21:03 +02:00
|
|
|
console.error(_('Fatal error:'));
|
2017-07-10 22:03:46 +02:00
|
|
|
console.error(error);
|
2017-06-22 23:52:27 +02:00
|
|
|
});
|