summaryrefslogtreecommitdiff
path: root/bin/wiki/ImportarDesdeURL/node_modules/tlds/cron.sh
blob: 679c6374157060daeb5196cccd17ea70d6a4b6e2 (plain)
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
#!/bin/sh

export EDITOR=true

if [ "x$NODE" = "x" ]; then
  NODE="node"
fi
if [ "x$NPM" = "x" ]; then
  NPM=$(which npm)
fi
if [ "x$SEMVER" = "x" ]; then
  SEMVER="$NODE $($NPM bin)/semver"
fi

# update `index.js`
$NODE update >/dev/null

# check if the working tree is "dirty"
git diff --quiet index.js
DIRTY=$?

# make sure the tests still pass
$NPM test >/dev/null 2>&1
TESTS_PASS=$?

if [ $DIRTY = "1" ] && [ $TESTS_PASS = "0" ]; then
  # commit the changes to the `index.js` file
  git add index.js
  git commit -m "index: update list from ICANN"
  VERSION=$($NODE -p "require('./package').version")
  INCREMENT=$($SEMVER --increment minor $VERSION)

  # update changelog
  git changelog
  sed -i.bak "s/n.n.n/$INCREMENT/" History.md
  rm History.md.bak

  # update package.json verison number
  $NODE -e "var fs = require('fs'); \
    var json = require('./package'); \
    json.version = '$INCREMENT'; \
    fs.writeFileSync('package.json', JSON.stringify(json, null, 2) + '\n');"

  # stage files and publish the new tag to git and npm
  git add History.md package.json
  git release $INCREMENT
  $NPM publish
fi;