Blame view

node_modules/aes-decrypter/scripts/version.js 1.67 KB
6a9ffbcc   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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
  import {exec} from 'child_process';
  import fs from 'fs';
  import path from 'path';
  
  /* eslint no-console: 0 */
  
  const pkg = require(path.join(__dirname, '../package.json'));
  
  /**
   * Determines whether or not the project has the CHANGELOG setup by checking
   * for the presence of a CHANGELOG.md file and the necessary dependency and
   * npm script.
   *
   * @return {Boolean}
   */
  const hasChangelog = () => {
    try {
      fs.statSync(path.join(__dirname, '../CHANGELOG.md'));
    } catch (x) {
      return false;
    }
    return pkg.devDependencies.hasOwnProperty('chg') &&
      pkg.scripts.hasOwnProperty('change');
  };
  
  /**
   * Determines whether or not the project has the Bower setup by checking for
   * the presence of a bower.json file.
   *
   * @return {Boolean}
   */
  const hasBower = () => {
    try {
      fs.statSync(path.join(__dirname, '../bower.json'));
      return true;
    } catch (x) {
      return false;
    }
  };
  
  const commands = [];
  
  // If the project has a CHANGELOG, update it for the new release.
  if (hasChangelog()) {
    commands.push(`chg release "${pkg.version}"`);
    commands.push('git add CHANGELOG.md');
  }
  
  // If the project supports Bower, perform special extra versioning step.
  if (hasBower()) {
    commands.push('git add package.json');
    commands.push(`git commit -m "${pkg.version}"`);
  
    // We only need a build in the Bower-supported case because of the
    // temporary addition of the dist/ directory.
    commands.push('npm run build');
    commands.push('git add -f dist');
  }
  
  if (commands.length) {
    exec(commands.join(' && '), (err, stdout, stderr) => {
      if (err) {
        process.stdout.write(err.stack);
        process.exit(err.status || 1);
      } else {
        process.stdout.write(stdout);
      }
    });
  }