xz -- optional dependency

This commit is contained in:
v 2019-01-14 11:52:18 +03:00
parent 4e23ea5d6f
commit 421ab5f05f
2 changed files with 33 additions and 20 deletions

View File

@ -12,6 +12,9 @@
"zim",
"pack"
],
"optionalDependencies": {
"xz": "^1.3.0"
},
"dependencies": {
"animated-gif-detector": "^1.2.0",
"cheerio": "*",
@ -41,8 +44,7 @@
"sharp": "^0.17.3",
"sqlite": "^2.8.0",
"sqlite3": "*",
"uuid": "*",
"xz": "^1.3.0"
"uuid": "*"
},
"engines": {
"node": ">=8.0.0"

View File

@ -7,34 +7,26 @@
/* MODULE VARIABLE SECTION **********/
/************************************/
const fs = require( 'fs-extra' )
var mimeDb = require( 'mime-db' );
var mime = require( 'mime-types' );
const os = require('os')
const osProcess = require('process')
const osPath = require( 'path' )
const expandHomeDir = require( 'expand-home-dir' )
const packageInfo = require('./package.json');
const fs = require( 'fs-extra' )
const mimeDb = require( 'mime-db' )
const mime = require( 'mime-types' )
const packageInfo = require('./package.json')
const genericPool = require( 'generic-pool' )
const asyncRead = require('promised-read').read
const cheerio = require('cheerio')
const command = require('commander')
const osProcess = require('process')
var osPath = require( 'path' );
var expandHomeDir = require( 'expand-home-dir' );
//~ var lzma = require('lzma-native');
var lzma = require('xz');
//~ var lzma = require('node-liblzma');
var csvOutput = require('csv-stringify');
const csvOutput = require('csv-stringify')
const moment = require("moment")
require("moment-duration-format")
var srcPath;
var outPath;
var src; // input file reader
var articles = null;
var metadata = [];
const startTime = Date.now()
function elapsedStr( from , to = Date.now()) {
@ -54,6 +46,25 @@ function fatal ( ...args ) {
osProcess.exit( 1 )
}
//~ var lzma = require('lzma-native')
try {
var lzma = require('xz')
} catch (er) {
if ( os.type() == 'Windows_NT' ) {
fatal( 'Module "xz" is not available on Windows' )
} else {
fatal( 'Module "xz" is required' )
}
}
//~ var lzma = require('node-liblzma')
var srcPath;
var outPath;
var src; // input file reader
var articles = null;
var metadata = [];
function readUInt64LE(buf, offset) {
var lowBits = buf.readUInt32LE(offset);
var highBits = buf.readUInt32LE(offset + 4);