Blame view

node_modules/pkcs7/lib/cli.js 943 Bytes
2a09d1a4   liuqimichale   添加宜春 天水 宣化
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  #! /usr/bin/env node
  
  'use strict';
  
  var pkcs7 = require('./pkcs7');
  var fs = require('fs');
  var path = require('path');
  
  var userArgs = process.argv;
  
  if (userArgs.indexOf('-h') !== -1 || userArgs.indexOf('--help') !== -1) {
    console.log('usage: pkcs7');
    return console.log('pkcs7 expects input on stdin and outputs to stdout');
  }
  
  if (userArgs.indexOf('-v') !== -1 || userArgs.indexOf('--version') !== -1) {
    return console.log(JSON.parse(fs.readFileSync(path.join(process.cwd(), 'package.json'))).version);
  }
  
  var data = [];
  process.stdin.on('readable', function() {
    var chunk = process.stdin.read();
    if (chunk !== null) {
      data.push(chunk);
    }
  });
  
  process.stdin.on('end', function() {
    var buffer = Buffer.concat(data),
        bytes = new Uint8Array(buffer.length),
        i = buffer.length;
  
    while (i--) {
      bytes[i] = buffer[i];
    }
  
    // output the padded input
    process.stdout.write(new Buffer(pkcs7.pad(bytes)));
  });