Commit c08f4517 authored by Philipp Nowinski's avatar Philipp Nowinski
Browse files

Merge branch 'v3' into 'master'

V3

See merge request toolchain/sgc-dev!3
parents c29c5514 9f35c679
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
charset = utf-8
# Get rid of whitespace to avoid diffs with a bunch of EOL changes
trim_trailing_whitespace = true
# Unix-style newlines with a newline ending every file
[*]
indent_style = tab
indent_size = 4
end_of_line = lf
insert_final_newline = true
# CSS-Files
[*.css]
indent_style = tab
indent_size = 4
# HTML-Files
[*.html]
indent_style = tab
indent_size = 4
# TMPL-Files
[*.tmpl]
indent_style = tab
indent_size = 4
# LESS-Files
[*.less]
indent_style = tab
indent_size = 4
# JS-Files
[*.js]
indent_style = tab
indent_size = 4
# JSON-Files
[*.json]
indent_style = tab
indent_size = 4
# PHP-Files
[*.php]
indent_style = tab
indent_size = 4
# ReST-Files
[*.rst]
indent_style = space
indent_size = 3
# MD-Files
[*.md]
indent_style = space
indent_size = 4
# package.json or .travis.yml
[{package.json,.travis.yml}]
indent_style = space
indent_size = 2
# TypoScript
[*.ts]
indent_style = tab
indent_size = 4
# XLF-Files
[*.xlf]
indent_style = tab
indent_size = 4
# SQL-Files
[*.sql]
indent_style = tab
indent_size = 2
module.exports = {
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"accessor-pairs": "error",
"array-bracket-spacing": "error",
"array-callback-return": "error",
"arrow-body-style": "error",
"arrow-parens": ["error", "as-needed"],
"arrow-spacing": "error",
"block-scoped-var": "error",
"block-spacing": "error",
"brace-style": [
"error",
"1tbs"
],
"callback-return": "error",
"camelcase": "error",
"capitalized-comments": "off",
"class-methods-use-this": "error",
"comma-dangle": "error",
"comma-spacing": [
"error",
{
"after": true,
"before": false
}
],
"comma-style": [
"error",
"last"
],
"complexity": "error",
"computed-property-spacing": [
"error",
"never"
],
"consistent-return": "error",
"consistent-this": "error",
"curly": "error",
"default-case": "error",
"dot-location": [
"error",
"property"
],
"dot-notation": "error",
"eol-last": "error",
"eqeqeq": "error",
"func-call-spacing": "error",
"func-name-matching": "error",
"func-names": [
"error",
"never"
],
"func-style": [
"error",
"declaration"
],
"generator-star-spacing": "error",
"global-require": "off",
"guard-for-in": "error",
"handle-callback-err": "error",
"id-blacklist": "error",
"id-length": "off",
"id-match": "error",
"indent": "off",
"init-declarations": "off",
"jsx-quotes": "error",
"key-spacing": "error",
"keyword-spacing": "off",
"line-comment-position": "error",
"linebreak-style": [
"error",
"unix"
],
"lines-around-comment": "error",
"lines-around-directive": "error",
"max-depth": "error",
"max-len": "off",
"max-lines": "error",
"max-nested-callbacks": "error",
"max-params": "error",
"max-statements": "off",
"max-statements-per-line": "error",
"multiline-ternary": "error",
"new-parens": "error",
"newline-after-var": "off",
"newline-before-return": "off",
"newline-per-chained-call": "off",
"no-alert": "error",
"no-array-constructor": "error",
"no-await-in-loop": "error",
"no-bitwise": "error",
"no-caller": "error",
"no-catch-shadow": "error",
"no-compare-neg-zero": "error",
"no-confusing-arrow": "error",
"no-continue": "error",
"no-div-regex": "error",
"no-duplicate-imports": "error",
"no-else-return": "error",
"no-empty-function": "error",
"no-eq-null": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
"no-extra-parens": "off",
"no-floating-decimal": "error",
"no-implicit-coercion": "error",
"no-implicit-globals": "error",
"no-implied-eval": "error",
"no-inline-comments": "error",
"no-inner-declarations": [
"error",
"functions"
],
"no-invalid-this": "off",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-lonely-if": "error",
"no-loop-func": "error",
"no-magic-numbers": "off",
"no-mixed-operators": "error",
"no-mixed-requires": "off",
"no-multi-assign": "error",
"no-multi-spaces": "error",
"no-multi-str": "error",
"no-multiple-empty-lines": "error",
"no-native-reassign": "error",
"no-negated-condition": "error",
"no-negated-in-lhs": "error",
"no-nested-ternary": "error",
"no-new": "off",
"no-new-func": "error",
"no-new-object": "error",
"no-new-require": "error",
"no-new-wrappers": "error",
"no-octal-escape": "error",
"no-param-reassign": "error",
"no-path-concat": "error",
"no-plusplus": [
"error",
{
"allowForLoopAfterthoughts": true
}
],
"no-process-env": "error",
"no-process-exit": "error",
"no-proto": "error",
"no-prototype-builtins": "off",
"no-restricted-globals": "error",
"no-restricted-imports": "error",
"no-restricted-modules": "error",
"no-restricted-properties": "error",
"no-restricted-syntax": "error",
"no-return-assign": "error",
"no-return-await": "error",
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow": "off",
"no-shadow-restricted-names": "error",
"no-spaced-func": "error",
"no-sync": "off",
"no-tabs": "off",
"no-template-curly-in-string": "error",
"no-ternary": "off",
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "error",
"no-undefined": "error",
"no-underscore-dangle": [2, { "allowAfterThis": true }],
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": "error",
"no-unused-expressions": "error",
"no-use-before-define": "off",
"no-useless-call": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "error",
"no-useless-constructor": "error",
"no-useless-escape": "error",
"no-useless-rename": "error",
"no-useless-return": "error",
"no-var": "off",
"no-void": "error",
"no-warning-comments": "error",
"no-whitespace-before-property": "error",
"no-with": "error",
"nonblock-statement-body-position": "error",
"object-curly-newline": "off",
"object-curly-spacing": [
"error",
"never"
],
"object-property-newline": [
"error",
{
"allowMultiplePropertiesPerLine": true
}
],
"object-shorthand": "off",
"one-var": "off",
"one-var-declaration-per-line": "error",
"operator-assignment": [
"error",
"always"
],
"operator-linebreak": "error",
"padded-blocks": "off",
"prefer-arrow-callback": "off",
"prefer-const": "off",
"prefer-destructuring": "error",
"prefer-numeric-literals": "error",
"prefer-promise-reject-errors": "error",
"prefer-reflect": "off",
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": "off",
"quote-props": "off",
"quotes": [
"error",
"single"
],
"radix": [
"error",
"as-needed"
],
"require-await": "error",
"require-jsdoc": "off",
"rest-spread-spacing": "error",
"semi": "error",
"semi-spacing": [
"error",
{
"after": true,
"before": false
}
],
"sort-imports": "off",
"sort-keys": "off",
"sort-vars": "off",
"space-before-blocks": "error",
"space-before-function-paren": "off",
"space-in-parens": [
"error",
"never"
],
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": [
"error",
"always"
],
"strict": "off",
"symbol-description": "error",
"template-curly-spacing": "error",
"template-tag-spacing": "error",
"unicode-bom": [
"error",
"never"
],
"valid-jsdoc": "off",
"vars-on-top": "off",
"wrap-iife": "error",
"wrap-regex": "error",
"yield-star-spacing": "error",
"yoda": [
"error",
"never"
]
}
};
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
lastUpdateCheck 1495625859628
yarn-offline-mirror "sgc-packages-offline-cache"
yarn-offline-mirror-pruning true
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xml:space="preserve"
enable-background="new 0 0 700.619 661.18"
viewBox="0 0 700.6201 821.97645"
height="821.97644"
width="700.62012"
y="0px"
x="0px"
id="Layer_1"
version="1.1"><metadata
id="metadata4559"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs4557" /><path
style="fill:#ac8000;fill-opacity:0.94117647"
id="path4550"
d="m 693.32606,76.056885 c -18.119,-18.793 -39.26,-34.662 -62.35,-54.355 -5.66,138.027005 -11.098,270.602005 -16.533,403.172005 -0.291,0.012 -1.344,27.896 -1.66,34.771 -1.084,23.414 -10.168,39.371 -24.508,49.357 -15.674,10.914 -82.267,11.531 -91.995,11.205 -52.186,-0.078 -287.017,2.047 -352.247,3.182 -38.678,0.674 -64.818003,-15.823 -61.923003,-63.692 6.541,-108.152 14.607,-216.213 21.974003,-324.315 2.047,-30.096 4.965,-58.845005 7.996,-89.375005 1.067,-13.953 20.29,-33.744 36.232,-40.859 10.071,-4.49699999 19.158,-4.52199999 19.267,-5.10099999 C 126.01106,1.423885 54.197057,57.206885 42.416057,95.597885 c -1.138,3.709 -1.879,7.621005 -2.209,11.486005 -4.769,55.574 -9.597,111.138 -14.092,166.734 -8.609,106.502 -16.7189996,213.046 -25.65599963,319.522 -3.73799997,44.535 15.29299963,67.664 59.26599963,67.711 187.305003,0.203 374.609003,0.146 561.917003,-0.037 38.971,-0.037 58.531,-18.11 60.412,-56.602 4.85,-98.979 9.489,-197.965 13.352,-296.983 2.605,-66.812 4.086,-133.678 5.197,-200.529 0.175,-10.449005 -0.913,-24.247005 -7.277,-30.843005 z" /><path
style="fill:#ffc10f;fill-opacity:0.94117647"
id="path4552"
d="m 614.18506,409.49689 c -3.113,-117.715 -6.295,-235.428 -9.094,-353.147005 -0.894,-37.551 -10.738,-48.493 -47.646,-49.207 -128.91,-2.483 -257.82,-4.881 -386.732,-7.13499999 -9.01,-0.156 -20.053,1.99799999 -31.01,6.88699999 -14.586,6.512 -26.681,19.973 -27.138,34.488 0.027,36.871 0.625,73.749005 -0.141,110.605005 -2.1,101.709 -5.16,203.4 -7.055,305.122 -0.541,29.086 13.493,45.254 42.188,46.979 62.724,3.75 127.883,6.01 195.248,8.619 61.871,2.387 122.916,4.264 184.797,6.391 -0.004,0.146 43.806,2.14 63.565,-11.623 14.639,-10.192 21.151,-26.553 22.155,-48.354 0.493,-10.557 1.025,-43.385 0.863,-49.625 z m -360.57,-228.748 c -1.759,4.474 -4.303,8.376 -7.631,11.704 -3.329,3.329 -7.43,5.952 -12.303,7.87 -4.874,1.917 -10.427,2.876 -16.658,2.876 -3.675,0 -7.258,-0.359 -10.745,-1.079 -3.488,-0.719 -6.817,-1.73 -9.985,-3.036 -3.17,-1.305 -6.141,-2.889 -8.908,-4.754 -2.771,-1.864 -5.247,-3.941 -7.43,-6.231 l 5.433,-8.948 c 0.479,-0.745 1.091,-1.331 1.837,-1.757 0.745,-0.426 1.57,-0.639 2.478,-0.639 1.225,0 2.583,0.573 4.074,1.718 1.49,1.146 3.288,2.396 5.394,3.755 2.104,1.358 4.646,2.61 7.63,3.755 2.981,1.146 6.551,1.718 10.705,1.718 6.764,0 11.996,-1.65 15.699,-4.954 3.7,-3.302 5.553,-7.855 5.553,-13.662 0,-3.248 -0.773,-5.898 -2.317,-7.949 -1.545,-2.05 -3.583,-3.768 -6.11,-5.153 -2.53,-1.385 -5.421,-2.557 -8.669,-3.516 -3.249,-0.958 -6.552,-1.983 -9.906,-3.076 -3.355,-1.091 -6.658,-2.369 -9.907,-3.835 -3.249,-1.464 -6.139,-3.381 -8.668,-5.752 -2.53,-2.37 -4.567,-5.299 -6.111,-8.788 -1.546,-3.488 -2.316,-7.842 -2.316,-13.062 0,-4.154 0.812,-8.175 2.437,-12.064 1.624,-3.887 3.995,-7.336005 7.11,-10.346005 3.116,-3.008 6.964,-5.419 11.545,-7.23 4.58,-1.81 9.799,-2.716 15.659,-2.716 6.604,0 12.663,1.039 18.175,3.116 5.513,2.077 10.267,5.033 14.261,8.868 l -4.554,8.948005 c -0.586,0.959 -1.198,1.666 -1.837,2.117 -0.641,0.453 -1.438,0.679 -2.397,0.679 -1.012,0 -2.145,-0.426 -3.396,-1.278 -1.252,-0.852 -2.796,-1.798 -4.634,-2.836 -1.837,-1.039 -4.009,-1.997 -6.512,-2.876 -2.504,-0.879 -5.485,-1.318 -8.947,-1.318 -3.195,0 -6.007,0.399 -8.43,1.199 -2.424,0.799 -4.461,1.917 -6.11,3.355 -1.651,1.438 -2.891,3.129 -3.716,5.073 -0.825,1.945 -1.237,4.062 -1.237,6.351 0,2.93 0.771,5.367 2.315,7.31 1.544,1.945 3.582,3.609 6.112,4.994 2.528,1.386 5.419,2.596 8.668,3.635 3.248,1.039 6.563,2.145 9.946,3.316 3.382,1.172 6.696,2.504 9.946,3.995 3.248,1.492 6.139,3.383 8.669,5.672 2.528,2.291 4.565,5.087 6.11,8.389 1.545,3.303 2.317,7.324 2.317,12.063 -0.002,5.111 -0.881,9.904 -2.639,14.379 z m 116.959,10.066 c -11.452,8.256 -24.767,12.383 -39.945,12.383 -9.321,0 -17.749,-1.451 -25.285,-4.354 -7.538,-2.902 -13.969,-6.951 -19.295,-12.144 -5.326,-5.193 -9.427,-11.384 -12.303,-18.575 -2.876,-7.191 -4.314,-15.1 -4.314,-23.728 0,-8.681 1.385,-16.63 4.154,-23.848 2.769,-7.216 6.736,-13.422 11.903,-18.615 5.165,-5.193005 11.396,-9.214005 18.694,-12.064005 7.297,-2.849 15.499,-4.274 24.606,-4.274 4.635,0 8.935,0.359 12.902,1.079 3.967,0.719 7.656,1.717 11.065,2.996 3.406,1.278 6.551,2.824 9.427,4.634 2.876,1.812 5.513,3.835 7.909,6.072005 l -5.354,8.549 c -0.853,1.332 -1.943,2.157 -3.274,2.477 -1.332,0.319 -2.771,0 -4.314,-0.959 -1.545,-0.905 -3.183,-1.863 -4.913,-2.876 -1.73,-1.011 -3.715,-1.958 -5.952,-2.836 -2.236,-0.879 -4.82,-1.598 -7.749,-2.157 -2.931,-0.559 -6.392,-0.839 -10.387,-0.839 -6.071,0 -11.544,0.999 -16.418,2.996 -4.873,1.997 -9.041,4.847 -12.503,8.548 -3.463,3.703 -6.125,8.188 -7.988,13.462 -1.865,5.273 -2.797,11.159 -2.797,17.656 0,6.871 0.984,13.01 2.956,18.415 1.971,5.407 4.767,9.987 8.39,13.742 3.621,3.755 8.002,6.619 13.142,8.588 5.14,1.971 10.878,2.956 17.218,2.956 4.739,0 8.96,-0.506 12.662,-1.518 3.701,-1.011 7.337,-2.423 10.905,-4.234 v -22.849 h -16.058 c -1.227,0 -2.185,-0.332 -2.877,-0.999 -0.691,-0.666 -1.038,-1.531 -1.038,-2.597 v -10.625 h 36.83 v 45.538 z m 94.832,7.789 c -6.817,3.063 -14.967,4.594 -24.445,4.594 -8.417,0 -16.02,-1.451 -22.811,-4.354 -6.791,-2.902 -12.583,-6.951 -17.377,-12.144 -4.793,-5.193 -8.482,-11.384 -11.063,-18.575 -2.585,-7.19 -3.875,-15.1 -3.875,-23.728 0,-8.628 1.369,-16.55 4.113,-23.768 2.742,-7.216 6.604,-13.422 11.584,-18.615 4.98,-5.193005 10.945,-9.228005 17.896,-12.104005 6.95,-2.876 14.605,-4.314 22.969,-4.314 8.309,0 15.646,1.346 22.011,4.035 6.363,2.69 11.891,6.271 16.577,10.745005 l -6.15,8.708 c -0.428,0.587 -0.934,1.092 -1.519,1.518 -0.587,0.427 -1.386,0.639 -2.396,0.639 -1.065,0 -2.276,-0.492 -3.636,-1.478 -1.357,-0.985 -3.09,-2.077 -5.192,-3.276 -2.104,-1.198 -4.741,-2.289 -7.909,-3.275 -3.169,-0.985 -7.124,-1.478 -11.864,-1.478 -5.486,0 -10.52,0.958 -15.1,2.876 -4.581,1.917 -8.521,4.714 -11.824,8.389 -3.303,3.675 -5.872,8.149 -7.709,13.422 -1.838,5.273 -2.757,11.265 -2.757,17.976 0,6.765 0.959,12.796 2.877,18.096 1.917,5.3 4.554,9.774 7.909,13.422 3.354,3.649 7.296,6.431 11.823,8.349 4.526,1.917 9.399,2.876 14.62,2.876 3.195,0 6.059,-0.172 8.588,-0.519 2.529,-0.346 4.86,-0.905 6.991,-1.678 2.129,-0.771 4.142,-1.744 6.031,-2.916 1.891,-1.171 3.768,-2.609 5.633,-4.314 1.064,-0.958 2.13,-1.438 3.195,-1.438 1.012,0 1.891,0.399 2.637,1.198 l 7.43,8.069 c -4.686,5.646 -10.438,10 -17.257,13.062 z" /><text
id="text5792"
y="820.80878"
x="49.86882"
style="font-style:normal;font-weight:normal;font-size:145.95573425px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ac8000;fill-opacity:0.94117647;stroke:none;stroke-width:3.64889336"
xml:space="preserve"><tspan
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Lato;-inkscape-font-specification:Lato;fill:#ac8000;fill-opacity:0.94117647;stroke-width:3.64889336"
y="820.80878"
x="49.86882"
id="tspan5790">Toolchain</tspan></text>
</svg>
\ No newline at end of file
......@@ -37,28 +37,31 @@ function setNodeVersion {
fi
}
if [ "$1" == "shortlist" ]; then
taskList="server images css css:sprites css:svg css:abovethefold images:uploaded js:compile js:qa js shortlist releaseExtension lighthouse"
COMMAND=$1
if [ "$COMMAND" == "shortlist" ]; then
taskList="server images css css:svg css:abovethefold images:uploaded js:compile js:qa js shortlist releaseExtension css:qa open"
if [ -e sgc-scripts ]
then
echo -e ${taskList} `ls sgc-scripts | grep .sh$ | cut -f 1 -d .`;
else
echo -e ${taskList}
fi
elif [ -e "sgc-core/core/modules/$1.sh" ]; then
elif [ -e "sgc-core/core/modules/$COMMAND.sh" ]; then
setNodeVersion
./sgc-core/core/modules/$1.sh $@
elif [ -e "./sgc-scripts/$1.sh" ]; then
./sgc-core/core/modules/$COMMAND.sh $@
elif [ -e "./sgc-scripts/$COMMAND.sh" ]; then
setNodeVersion
./sgc-scripts/$1.sh
elif [ -e "./sgc-scripts/$1.js" ]; then
shift
./sgc-scripts/$COMMAND.sh $@
elif [ -e "./sgc-scripts/$COMMAND.js" ]; then
setNodeVersion
node ./sgc-scripts/$1.js
elif [ -e "./sgc-core/core/modules/$1.js" ]; then
node ./sgc-scripts/$COMMAND.js
elif [ -e "./sgc-core/core/modules/$COMMAND.js" ]; then
setNodeVersion
node ./sgc-core/core/modules/$1.js $@
node ./sgc-core/core/modules/$COMMAND.js $@
else
setNodeVersion
cd sgc-core
node ./node_modules/gulp/bin/gulp.js $@
node ./core/run.js $@
fi
'use strict';
const settings = require('../gulp/settings');
const config = settings.getConfig();
let extensions = config.extensions.reduce((accumulator, currentValue) => accumulator + ' ' + currentValue);
// intended as an information output
console.log(extensions);
......@@ -6,12 +6,25 @@ nvm_has() {
type "$1" > /dev/null 2>&1
}
if [ -z "$NVM_DIR" ]; then
NVM_DIR="$HOME/.nvm"
fi
nvm_install_dir() {
command printf %s "${NVM_DIR:-"$HOME/.nvm"}"
}
nvm_latest_version() {
echo "v0.31.2"
echo "v0.33.11"
}
nvm_profile_is_bash_or_zsh() {
local TEST_PROFILE
TEST_PROFILE="${1-}"
case "${TEST_PROFILE-}" in
*"/.bashrc" | *"/.bash_profile" | *"/.zshrc")
return
;;
*)
return 1
;;
esac
}
#
......@@ -27,6 +40,8 @@ nvm_source() {
NVM_SOURCE_URL="$NVM_SOURCE"
if [ "_$NVM_METHOD" = "_script-nvm-exec" ]; then
NVM_SOURCE_URL="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/nvm-exec"
elif [ "_$NVM_METHOD" = "_script-nvm-bash-completion" ]; then
NVM_SOURCE_URL="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/bash_completion"
elif [ -z "$NVM_SOURCE_URL" ]; then
if [ "_$NVM_METHOD" = "_script" ]; then
NVM_SOURCE_URL="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/nvm.sh"
......@@ -40,74 +55,156 @@ nvm_source() {
echo "$NVM_SOURCE_URL"
}
#
# Node.js version to install
#
nvm_node_version() {
echo "$NODE_VERSION"
}
nvm_download() {
if nvm_has "curl"; then
curl -q $*
curl --compressed -q "$@"
elif nvm_has "wget"; then
# Emulate curl with wget
ARGS=$(echo "$*" | command sed -e 's/--progress-bar /--progress=bar /' \
-e 's/-L //' \
-e 's/-I /--server-response /' \
-e 's/-s /-q /' \
-e 's/-o /-O /' \
-e 's/-C - /-c /')
wget $ARGS
-e 's/-L //' \
-e 's/--compressed //' \
-e 's/-I /--server-response /' \
-e 's/-s /-q /' \
-e 's/-o /-O /' \
-e 's/-C - /-c /')
# shellcheck disable=SC2086
eval wget $ARGS
fi
}
install_nvm_from_git() {
if [ -d "$NVM_DIR/.git" ]; then
echo "=> nvm is already installed in $NVM_DIR, trying to update using git"
printf "\r=> "
cd "$NVM_DIR" && (command git fetch 2> /dev/null || {
echo >&2 "Failed to update nvm, run 'git fetch' in $NVM_DIR yourself." && exit 1
})
local INSTALL_DIR
INSTALL_DIR="$(nvm_install_dir)"
if [ -d "$INSTALL_DIR/.git" ]; then
echo "=> nvm is already installed in $INSTALL_DIR, trying to update using git"
command printf '\r=> '
command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch origin tag "$(nvm_latest_version)" --depth=1 2> /dev/null || {
echo >&2 "Failed to update nvm, run 'git fetch' in $INSTALL_DIR yourself."
exit 1
}
else
# Cloning to $NVM_DIR
echo "=> Downloading nvm from git to '$NVM_DIR'"
printf "\r=> "
mkdir -p "$NVM_DIR"
command git clone "$(nvm_source git)" "$NVM_DIR"
# Cloning to $INSTALL_DIR
echo "=> Downloading nvm from git to '$INSTALL_DIR'"
command printf '\r=> '
mkdir -p "${INSTALL_DIR}"
if [ "$(ls -A "${INSTALL_DIR}")" ]; then
command git init "${INSTALL_DIR}" || {
echo >&2 'Failed to initialize nvm repo. Please report this!'
exit 2
}
command git --git-dir="${INSTALL_DIR}/.git" remote add origin "$(nvm_source)" 2> /dev/null \
|| command git --git-dir="${INSTALL_DIR}/.git" remote set-url origin "$(nvm_source)" || {
echo >&2 'Failed to add remote "origin" (or set the URL). Please report this!'
exit 2
}
command git --git-dir="${INSTALL_DIR}/.git" fetch origin tag "$(nvm_latest_version)" --depth=1 || {
echo >&2 'Failed to fetch origin with tags. Please report this!'
exit 2
}
else
command git -c advice.detachedHead=false clone "$(nvm_source)" -b "$(nvm_latest_version)" --depth=1 "${INSTALL_DIR}" || {
echo >&2 'Failed to clone nvm repo. Please report this!'
exit 2
}
fi
fi
cd "$NVM_DIR" && command git checkout --quiet "$(nvm_latest_version)"
if [ ! -z "$(cd "$NVM_DIR" && git show-ref refs/heads/master)" ]; then
if git branch --quiet 2>/dev/null; then
cd "$NVM_DIR" && command git branch --quiet -D master >/dev/null 2>&1
command git -c advice.detachedHead=false --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" checkout -f --quiet "$(nvm_latest_version)"
if [ ! -z "$(command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" show-ref refs/heads/master)" ]; then
if command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet 2>/dev/null; then
command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet -D master >/dev/null 2>&1
else
echo >&2 "Your version of git is out of date. Please update it!"
cd "$NVM_DIR" && command git branch -D master >/dev/null 2>&1
command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch -D master >/dev/null 2>&1
fi
fi
echo "=> Compressing and cleaning up git repository"
if ! command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" reflog expire --expire=now --all; then
echo >&2 "Your version of git is out of date. Please update it!"
fi
if ! command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" gc --auto --aggressive --prune=now ; then
echo >&2 "Your version of git is out of date. Please update it!"
fi
return
}