Skip to content

Latest commit

 

History

History
24 lines (21 loc) · 632 Bytes

File metadata and controls

24 lines (21 loc) · 632 Bytes

node-mscabinet

Example

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

const extract = new Extract();
const dist = './dist';
fs.createReadStream('input.cab').pipe(extract)
    .on('entry', (file: CFFile, stream, next) => {
        const target = path.resolve(dist, '.' + file.name);
        const dirname = path.dirname(target);
        fs.mkdirSync(dirname, {recursive: true});
        stream
            .pipe(fs.createWriteStream(target))
            .on('finish', () => next());
    })
    .on('close', () => {
        console.log("ONCLOSE");
    });