1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-30 08:26:59 +02:00
joplin/CliClientDemo/index.js

31 lines
763 B
JavaScript

#!/usr/bin/env node
'use strict';
const spawn = require('child_process').spawn;
const os = require('os');
const fs = require('fs-extra');
const joplinPath = __dirname + '/node_modules/.bin/joplin';
const profileDir = os.homedir() + '/.config/demo-joplin';
const dbFilename = 'database.sqlite';
fs.ensureDirSync(profileDir);
if (!fs.pathExistsSync(profileDir + '/' + dbFilename)) {
fs.copySync(__dirname + '/' + dbFilename, profileDir + '/' + dbFilename);
}
const opt = {
cwd: __dirname,
env: (function() {
process.env.NODE_PATH = '.';
return process.env;
}()),
stdio: [process.stdin, process.stdout, process.stderr]
};
const app = spawn(joplinPath, ['--is-demo', '--profile', profileDir], opt);
app.on('close', (code) => {
process.exit(code);
});