|
| 1 | +// Copyright (C) 2015-2016 IBM Corporation and Others. All Rights Reserved. |
| 2 | + |
| 3 | +// Install by using spawn |
| 4 | + |
| 5 | +// var fs = require('fs'); |
| 6 | +const {URL} = require('url'); |
| 7 | +const process = require('process'); |
| 8 | +const myFetch = require('./myFetch'); |
| 9 | +// const yauzl = require('yauzl'); |
| 10 | + |
| 11 | +// var isglobal = process.env.npm_config_global === 'true'; |
| 12 | + |
| 13 | +module.exports = async function installFromGithub(fullIcu, advice) { |
| 14 | + var icupkg = fullIcu.icupkg; |
| 15 | + var icudat = fullIcu.icudat; |
| 16 | + |
| 17 | + // var cmdPath = nodePath = process.env.npm_node_execpath; |
| 18 | + |
| 19 | + // var npmPath = process.env.npm_execpath; |
| 20 | + |
| 21 | + // var args; |
| 22 | + // https://github.com/unicode-org/icu/releases/download/release-51-3/icu4c-51_3-src.zip |
| 23 | + const _baseUrl = process.env.FULL_ICU_BASEURL || 'https://github.com/unicode-org/icu/releases/'; |
| 24 | + const baseUrl = new URL(_baseUrl); |
| 25 | + const versionsAsHyphen = fullIcu.icuver.replace(/\./g, '-'); |
| 26 | + const versionsAsUnderscore = fullIcu.icuver.replace(/\./g, '_'); |
| 27 | + const tag = `release-${versionsAsHyphen}`; |
| 28 | + const file = `icu4c-${versionsAsUnderscore}-src.zip`; |
| 29 | + const fullUrl = new URL(`./download/${tag}/${file}`, baseUrl); |
| 30 | + console.log(fullUrl.toString()); |
| 31 | + const [srcZip, tmpd] = await myFetch(fullUrl); |
| 32 | + |
| 33 | + console.log(srcZip, tmpd); |
| 34 | + // now, unpack it |
| 35 | + |
| 36 | +/* |
| 37 | + if(spawned.error) { |
| 38 | + throw(spawned.error); |
| 39 | + } else if(spawned.status !== 0) { |
| 40 | + throw(Error(cmdPath + ' ' + args.join(' ') + ' --> status ' + spawned.status)); |
| 41 | + } else { |
| 42 | + var datPath; |
| 43 | + if(fs.existsSync(icudat)) { |
| 44 | + console.log(' √ ' + icudat + " (existing link?)"); |
| 45 | + } else if(!fs.existsSync(datPath)) { |
| 46 | + console.log(' • ' + ' (no ' + icudat + ' at ‘' + datPath+'’)'); |
| 47 | + } else { |
| 48 | + try { |
| 49 | + fs.linkSync(datPath, icudat); |
| 50 | + console.log(' √ ' + icudat + " (link)"); |
| 51 | + } catch(e) { |
| 52 | + fs.symlinkSync(datPath, icudat); |
| 53 | + console.log(' √ ' + icudat + " (symlink)"); |
| 54 | + } |
| 55 | + } |
| 56 | + if(!fullIcu.haveDat()) { |
| 57 | + throw Error('Somehow failed to install ' + icudat); |
| 58 | + } else { |
| 59 | + advice(); |
| 60 | + } |
| 61 | + }*/ |
| 62 | +}; |
0 commit comments