Commit 49058f5f9a406656f03018486b4535f0bcb5250b
Make bootstrap snippet idempotent and more robust
cel committed on 8/30/2018, 3:21:35 AMParent: 8c002450411e07771334a9760bce28ba16957a1e
Files changed
index.js | changed |
index.js | |||
---|---|---|---|
@@ -581,8 +581,9 @@ | |||
581 | 581 … | var self = this | |
582 | 582 … | var pkgs = self.server.npmConfig.defaultPkgs || ['scuttlebot', 'ssb-npm', 'git-ssb'] | |
583 | 583 … | var ssbNpmRegistryName = require('./package.json').name | |
584 | 584 … | var ssbNpmRegistryVersion = require('./package.json').version | |
585 … | + var ssbNpmRegistryNameVersion = ssbNpmRegistryName + '-' + ssbNpmRegistryVersion | ||
585 | 586 … | var ssbNpmRegistrySpec = ssbNpmRegistryName + '@^' + ssbNpmRegistryVersion | |
586 | 587 … | var done = multicb({pluck: 1, spread: true}) | |
587 | 588 … | self.resolvePkg(ssbNpmRegistrySpec, done()) | |
588 | 589 … | self.resolvePkgs(pkgs, done()) | |
@@ -595,18 +596,17 @@ | |||
595 | 596 … | var globalPkgs = pkgsInfo.map(function (info) { | |
596 | 597 … | return info.name + '@' + info.version | |
597 | 598 … | }).join(' ') | |
598 | 599 … | var npmCmd = 'install -g ' + globalPkgs | |
599 | - var pkgTmpText = '/tmp/' + ssbNpmRegistryName + '.tar.gz' | ||
600 … | + var tmpDir = '/tmp/' + encodeURIComponent(ssbNpmRegistryNameVersion) | ||
600 | 601 … | var tarballLink = self.wsLink + '/blobs/get/' + ssbNpmRegistryBlobId | |
601 | 602 … | ||
602 | 603 … | var script = | |
603 | - 'wget \'' + tarballLink + '\' -O ' + pkgTmpText + ' &&\n' + | ||
604 | - 'echo \'' + ssbNpmRegistryBlobHex + ' ' + pkgTmpText + '\' | sha256sum -c &&\n' + | ||
605 | - 'mkdir -p ~/.ssb/node_modules && cd ~/.ssb/node_modules &&\n' + | ||
606 | - 'tar xzf ' + pkgTmpText + ' &&\n' + | ||
607 | - 'mv package ' + ssbNpmRegistryName + ' &&\n' + | ||
608 | - ssbNpmRegistryName + '/bootstrap/bin.js --ws-url ' + self.wsLink + ' \\\n' + | ||
604 … | + 'mkdir -p ' + tmpDir + ' && cd ' + tmpDir + ' &&\n' + | ||
605 … | + 'wget -q \'' + tarballLink + '\' -O package.tgz &&\n' + | ||
606 … | + 'echo \'' + ssbNpmRegistryBlobHex + ' package.tgz\' | sha256sum -c &&\n' + | ||
607 … | + 'tar xzf package.tgz &&\n' + | ||
608 … | + './*/bootstrap/bin.js --ws-url ' + self.wsLink + ' \\\n' + | ||
609 | 609 … | pkgMsgs.map(function (id) { | |
610 | 610 … | return ' --branch ' + id + ' \\\n' | |
611 | 611 … | }).join('') + | |
612 | 612 … | ' -- ' + npmCmd + ' &&\n' + |
Built with git-ssb-web