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

View File

@ -7,34 +7,26 @@
/* MODULE VARIABLE SECTION **********/ /* MODULE VARIABLE SECTION **********/
/************************************/ /************************************/
const fs = require( 'fs-extra' ) const os = require('os')
var mimeDb = require( 'mime-db' ); const osProcess = require('process')
var mime = require( 'mime-types' ); 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 genericPool = require( 'generic-pool' )
const asyncRead = require('promised-read').read const asyncRead = require('promised-read').read
const cheerio = require('cheerio') const cheerio = require('cheerio')
const command = require('commander') const command = require('commander')
const osProcess = require('process') const csvOutput = require('csv-stringify')
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 moment = require("moment") const moment = require("moment")
require("moment-duration-format") require("moment-duration-format")
var srcPath;
var outPath;
var src; // input file reader
var articles = null;
var metadata = [];
const startTime = Date.now() const startTime = Date.now()
function elapsedStr( from , to = Date.now()) { function elapsedStr( from , to = Date.now()) {
@ -54,6 +46,25 @@ function fatal ( ...args ) {
osProcess.exit( 1 ) 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) { function readUInt64LE(buf, offset) {
var lowBits = buf.readUInt32LE(offset); var lowBits = buf.readUInt32LE(offset);
var highBits = buf.readUInt32LE(offset + 4); var highBits = buf.readUInt32LE(offset + 4);