1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00
joplin/CliClient/app/main.js

61 lines
1.8 KiB
JavaScript
Raw Normal View History

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-11-03 20:39:08 +02:00
require('app-module-path').addPath(__dirname);
2017-06-22 23:52:27 +02:00
const { app } = require('./app.js');
const { BaseModel } = require('lib/base-model.js');
const { Folder } = require('lib/models/folder.js');
const { Resource } = require('lib/models/resource.js');
const { BaseItem } = require('lib/models/base-item.js');
const { Note } = require('lib/models/note.js');
const { Tag } = require('lib/models/tag.js');
const { NoteTag } = require('lib/models/note-tag.js');
const { Setting } = require('lib/models/setting.js');
const { Logger } = require('lib/logger.js');
const { FsDriverNode } = require('lib/fs-driver-node.js');
const { shimInit } = require('lib/shim-init-node.js');
const { _ } = require('lib/locale.js');
2017-06-22 23:52:27 +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');
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.stdout.on('error', function( err ) {
// https://stackoverflow.com/questions/12329816/error-write-epipe-when-piping-node-output-to-head#15884508
if (err.code == "EPIPE") {
process.exit(0);
}
});
application.start(process.argv).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
});