yuque2book
Version:
convert yuque book to a static book
31 lines (30 loc) • 1.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var fs = require("fs");
var os = require("os");
var path = require("path");
var debug = require("debug");
var program = require("commander");
var index_1 = require("./lib/index");
var log = debug('yuque2book');
var pkg = require('../package.json');
program.version(pkg.version)
.option('-t, --token <n>', 'your yuque token 你的语雀token')
.option('-l, --local ', 'to localize image and attach')
.parse(process.argv);
var bookUrl = program.args[0];
var token = program.token;
try {
var configPath = path.join(os.homedir(), '.yuque2book.json');
var json = JSON.parse(fs.readFileSync(configPath).toString());
token = token || json.token;
}
catch (e) {
log('[NO CONFIG]', e);
}
if (!bookUrl || !token) {
console.warn('[waring] program need token & book url, but get url %s, token %s', bookUrl, program.token);
process.exit(0);
}
index_1.default(token, bookUrl, program.local);