UNPKG

mscabinet

Version:

```javascript import { Extract, CFFile } from 'cabinet'; import * as path from 'path'; import * as fs from 'fs';

31 lines 1.22 kB
"use strict"; var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; return result; }; Object.defineProperty(exports, "__esModule", { value: true }); const src_1 = require("./src"); const path = __importStar(require("path")); const fs = __importStar(require("fs")); const extract = new src_1.Extract(); fs.createReadStream('D:\\temp\\out_sp76944.cab').pipe(extract) .on('entry', (file, stream, next) => { const dir = "D:\\jcworkspace\\mscabinet\\test_out"; const target = path.resolve(dir, '.' + file.name); const dirname = path.dirname(target); fs.mkdirSync(dirname, { recursive: true }); console.log("ENTRY : ", file); stream .pipe(fs.createWriteStream(target, { autoClose: false })) .on('close', () => { console.log("************* ENTRY CLOSE *****************"); next(); }); }) .on('close', () => { console.log("ONCLOSE"); }) .on('error', (err) => { console.log("ERROR", err); }); //# sourceMappingURL=test.js.map