Commit 50bce98b authored by Víctor Gallego Fontenla's avatar Víctor Gallego Fontenla 🏉

Fix error when installing dictionary for language with multiple variants

parent 8a92df99
...@@ -59,14 +59,14 @@ async function installDict(language){ ...@@ -59,14 +59,14 @@ async function installDict(language){
const packageName = `dictionary-${languageCode}` const packageName = `dictionary-${languageCode}`
const search = await run(`npm search ${packageName}`) const search = await run(`npm search ${packageName}`)
const dictionaries = search.stdout.split('\n').map(line => line.split('|')).map(([name]) => name.trim()).filter(name => name === packageName) const dictionaries = search.stdout.split('\n').map(line => line.split('|')).map(([name]) => name.trim()).filter(name => name.startsWith(packageName))
stopPrinting() stopPrinting()
if(dictionaries.length === 1){ if(dictionaries.length === 1){
clear() clear()
printLoading(`${Chalk.blue.bold("Installing dictionary")} ${Chalk.whiteBright.underline.italic(dictionaries[0])}`) printLoading(`${Chalk.blue.bold("Installing dictionary")} ${Chalk.whiteBright.underline.italic(dictionaries[0])}`)
await run(`npm install ${dictionaries[0]}`) await run(`cd ${__dirname} && npm install ${dictionaries[0]}`)
stopPrinting() stopPrinting()
clear() clear()
println(`${Chalk.green.bold("Dictionary")} ${Chalk.whiteBright.underline.italic(dictionaries[0])} ${Chalk.green.bold("installed successfully!")}`) println(`${Chalk.green.bold("Dictionary")} ${Chalk.whiteBright.underline.italic(dictionaries[0])} ${Chalk.green.bold("installed successfully!")}`)
...@@ -74,13 +74,20 @@ async function installDict(language){ ...@@ -74,13 +74,20 @@ async function installDict(language){
clear() clear()
println(Chalk.red.bold(`Dictionary for language ${Chalk.underline.italic(language)} not found!`)) println(Chalk.red.bold(`Dictionary for language ${Chalk.underline.italic(language)} not found!`))
} else { } else {
println(Chalk.bgRed.bold.underline("ERROR! More than one dictionary found for the specified language!")) println(Chalk.blue.bold.underline("More than one dictionary found for the specified language!"))
const { dictionary } = await Inquirer.prompt({type: 'list', message:"Select one:", name: 'dictionary', choices: dictionaries, default: 0})
clear()
printLoading(`${Chalk.blue.bold("Installing dictionary")} ${Chalk.whiteBright.underline.italic(dictionary)}`)
await run(`cd ${__dirname} && npm install ${dictionary}`)
stopPrinting()
clear()
println(`${Chalk.green.bold("Dictionary")} ${Chalk.whiteBright.underline.italic(dictionary)} ${Chalk.green.bold("installed successfully!")}`)
} }
} }
async function listInstalledDict(){ async function listInstalledDict(){
clear() clear()
printLoading(Chalk.blue.bold("Searching for installed dictionaires")) printLoading(Chalk.blue.bold("Searching for installed dictionaires"))
const installed = await run('npm ls --depth=0 --json') const installed = await run(`cd ${__dirname} && npm ls --depth=0 --json`)
const packages = Object.entries(JSON.parse(installed.stdout).dependencies).map(([name]) => name).filter(name => name.includes("dictionary")) const packages = Object.entries(JSON.parse(installed.stdout).dependencies).map(([name]) => name).filter(name => name.includes("dictionary"))
stopPrinting() stopPrinting()
clear() clear()
...@@ -110,7 +117,7 @@ async function uninstallDict(language){ ...@@ -110,7 +117,7 @@ async function uninstallDict(language){
].filter(x => x !== undefined)[0] ].filter(x => x !== undefined)[0]
const languageCode = languageDefinition !== undefined ? languageDefinition['1'] : '' const languageCode = languageDefinition !== undefined ? languageDefinition['1'] : ''
const installed = await run('npm ls --depth=0 --json') const installed = await run(`cd ${__dirname} && npm ls --depth=0 --json`)
const packages = Object.entries(JSON.parse(installed.stdout).dependencies) const packages = Object.entries(JSON.parse(installed.stdout).dependencies)
.map(([name]) => name) .map(([name]) => name)
.filter(name => name.includes("dictionary")) .filter(name => name.includes("dictionary"))
...@@ -121,7 +128,7 @@ async function uninstallDict(language){ ...@@ -121,7 +128,7 @@ async function uninstallDict(language){
clear() clear()
println(Chalk.red.bold(`Dictionary for language ${Chalk.whiteBright.underline.italic(language)} not found!`)) println(Chalk.red.bold(`Dictionary for language ${Chalk.whiteBright.underline.italic(language)} not found!`))
} else { } else {
await run(`npm remove ${packages[0]}`) await run(`cd ${__dirname} && npm remove ${packages[0]}`)
stopPrinting() stopPrinting()
clear() clear()
println(Chalk.green.bold(`Dictionary ${packages[0]} uninstalled successfully!`)) println(Chalk.green.bold(`Dictionary ${packages[0]} uninstalled successfully!`))
......
{ {
"name": "POTrans", "name": "@morrisgallego/potrans",
"version": "1.0.1", "version": "1.0.1",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true,
"dependencies": { "dependencies": {
"ansi-escapes": { "ansi-escapes": {
"version": "3.0.0", "version": "3.0.0",
...@@ -16,7 +17,10 @@ ...@@ -16,7 +17,10 @@
"ansi-styles": { "ansi-styles": {
"version": "3.2.0", "version": "3.2.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz",
"integrity": "sha1-wVm41b4PnlpvNG2rlPFs4CIWG4g=" "integrity": "sha1-wVm41b4PnlpvNG2rlPFs4CIWG4g=",
"requires": {
"color-convert": "1.9.1"
}
}, },
"array-unique": { "array-unique": {
"version": "0.1.1", "version": "0.1.1",
...@@ -26,12 +30,20 @@ ...@@ -26,12 +30,20 @@
"async": { "async": {
"version": "2.6.0", "version": "2.6.0",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz", "resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz",
"integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==" "integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==",
"requires": {
"lodash": "4.17.5"
}
}, },
"chalk": { "chalk": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz",
"integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==" "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==",
"requires": {
"ansi-styles": "3.2.0",
"escape-string-regexp": "1.0.5",
"supports-color": "4.5.0"
}
}, },
"chardet": { "chardet": {
"version": "0.4.2", "version": "0.4.2",
...@@ -41,7 +53,10 @@ ...@@ -41,7 +53,10 @@
"cli-cursor": { "cli-cursor": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz",
"integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=" "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=",
"requires": {
"restore-cursor": "2.0.0"
}
}, },
"cli-width": { "cli-width": {
"version": "2.2.0", "version": "2.2.0",
...@@ -51,7 +66,10 @@ ...@@ -51,7 +66,10 @@
"color-convert": { "color-convert": {
"version": "1.9.1", "version": "1.9.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz",
"integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=" "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=",
"requires": {
"color-name": "1.1.3"
}
}, },
"color-name": { "color-name": {
"version": "1.1.3", "version": "1.1.3",
...@@ -71,12 +89,20 @@ ...@@ -71,12 +89,20 @@
"external-editor": { "external-editor": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.1.0.tgz", "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.1.0.tgz",
"integrity": "sha512-E44iT5QVOUJBKij4IIV3uvxuNlbKS38Tw1HiupxEIHPv9qtC2PrDYohbXV5U+1jnfIXttny8gUhj+oZvflFlzA==" "integrity": "sha512-E44iT5QVOUJBKij4IIV3uvxuNlbKS38Tw1HiupxEIHPv9qtC2PrDYohbXV5U+1jnfIXttny8gUhj+oZvflFlzA==",
"requires": {
"chardet": "0.4.2",
"iconv-lite": "0.4.19",
"tmp": "0.0.33"
}
}, },
"figures": { "figures": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz",
"integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=" "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=",
"requires": {
"escape-string-regexp": "1.0.5"
}
}, },
"has-flag": { "has-flag": {
"version": "2.0.0", "version": "2.0.0",
...@@ -96,7 +122,22 @@ ...@@ -96,7 +122,22 @@
"inquirer": { "inquirer": {
"version": "5.1.0", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/inquirer/-/inquirer-5.1.0.tgz", "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-5.1.0.tgz",
"integrity": "sha512-kn7N70US1MSZHZHSGJLiZ7iCwwncc7b0gc68YtlX29OjI3Mp0tSVV+snVXpZ1G+ONS3Ac9zd1m6hve2ibLDYfA==" "integrity": "sha512-kn7N70US1MSZHZHSGJLiZ7iCwwncc7b0gc68YtlX29OjI3Mp0tSVV+snVXpZ1G+ONS3Ac9zd1m6hve2ibLDYfA==",
"requires": {
"ansi-escapes": "3.0.0",
"chalk": "2.3.0",
"cli-cursor": "2.1.0",
"cli-width": "2.2.0",
"external-editor": "2.1.0",
"figures": "2.0.0",
"lodash": "4.17.5",
"mute-stream": "0.0.7",
"run-async": "2.3.0",
"rxjs": "5.5.6",
"string-width": "2.1.1",
"strip-ansi": "4.0.0",
"through": "2.3.8"
}
}, },
"is-fullwidth-code-point": { "is-fullwidth-code-point": {
"version": "2.0.0", "version": "2.0.0",
...@@ -136,12 +177,21 @@ ...@@ -136,12 +177,21 @@
"nodehun-sentences": { "nodehun-sentences": {
"version": "1.0.4", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/nodehun-sentences/-/nodehun-sentences-1.0.4.tgz", "resolved": "https://registry.npmjs.org/nodehun-sentences/-/nodehun-sentences-1.0.4.tgz",
"integrity": "sha1-pK7y13B9fVaBM4BulXpqSrnrkQY=" "integrity": "sha1-pK7y13B9fVaBM4BulXpqSrnrkQY=",
"requires": {
"async": "2.6.0",
"in-publish": "2.0.0",
"partial": "0.0.3",
"unique-words": "1.0.0"
}
}, },
"onetime": { "onetime": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz",
"integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=" "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=",
"requires": {
"mimic-fn": "1.2.0"
}
}, },
"os-tmpdir": { "os-tmpdir": {
"version": "1.0.2", "version": "1.0.2",
...@@ -161,17 +211,27 @@ ...@@ -161,17 +211,27 @@
"restore-cursor": { "restore-cursor": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz",
"integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=" "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=",
"requires": {
"onetime": "2.0.1",
"signal-exit": "3.0.2"
}
}, },
"run-async": { "run-async": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz",
"integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=" "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=",
"requires": {
"is-promise": "2.1.0"
}
}, },
"rxjs": { "rxjs": {
"version": "5.5.6", "version": "5.5.6",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.5.6.tgz", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.5.6.tgz",
"integrity": "sha512-v4Q5HDC0FHAQ7zcBX7T2IL6O5ltl1a2GX4ENjPXg6SjDY69Cmx9v4113C99a4wGF16ClPv5Z8mghuYorVkg/kg==" "integrity": "sha512-v4Q5HDC0FHAQ7zcBX7T2IL6O5ltl1a2GX4ENjPXg6SjDY69Cmx9v4113C99a4wGF16ClPv5Z8mghuYorVkg/kg==",
"requires": {
"symbol-observable": "1.0.1"
}
}, },
"signal-exit": { "signal-exit": {
"version": "3.0.2", "version": "3.0.2",
...@@ -181,17 +241,27 @@ ...@@ -181,17 +241,27 @@
"string-width": { "string-width": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",
"integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==" "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==",
"requires": {
"is-fullwidth-code-point": "2.0.0",
"strip-ansi": "4.0.0"
}
}, },
"strip-ansi": { "strip-ansi": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
"integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=" "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=",
"requires": {
"ansi-regex": "3.0.0"
}
}, },
"supports-color": { "supports-color": {
"version": "4.5.0", "version": "4.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz",
"integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=" "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=",
"requires": {
"has-flag": "2.0.0"
}
}, },
"symbol-observable": { "symbol-observable": {
"version": "1.0.1", "version": "1.0.1",
...@@ -206,12 +276,18 @@ ...@@ -206,12 +276,18 @@
"tmp": { "tmp": {
"version": "0.0.33", "version": "0.0.33",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
"integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==" "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==",
"requires": {
"os-tmpdir": "1.0.2"
}
}, },
"unique-words": { "unique-words": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/unique-words/-/unique-words-1.0.0.tgz", "resolved": "https://registry.npmjs.org/unique-words/-/unique-words-1.0.0.tgz",
"integrity": "sha1-QLJqGfmAYWY8gTzZehogp/i1WZA=" "integrity": "sha1-QLJqGfmAYWY8gTzZehogp/i1WZA=",
"requires": {
"array-unique": "0.1.1"
}
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment