palabra 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog +6 -0
- package/letras/go.json +9 -0
- package/lib/hablar.js +0 -2
- package/lib/parser/parser.js +33 -5
- package/lib/parser/unpack.js +3 -4
- package/package.json +1 -1
package/ChangeLog
CHANGED
package/letras/go.json
ADDED
package/lib/hablar.js
CHANGED
package/lib/parser/parser.js
CHANGED
|
@@ -2,6 +2,10 @@ import {extname, join} from 'node:path';
|
|
|
2
2
|
import {unpack} from './unpack.js';
|
|
3
3
|
import {execute} from './execute.js';
|
|
4
4
|
|
|
5
|
+
const {entries} = Object;
|
|
6
|
+
|
|
7
|
+
const isString = (a) => typeof a === 'string';
|
|
8
|
+
|
|
5
9
|
export const parse = (letra) => {
|
|
6
10
|
const commands = [];
|
|
7
11
|
const {
|
|
@@ -11,18 +15,42 @@ export const parse = (letra) => {
|
|
|
11
15
|
camino,
|
|
12
16
|
} = letra;
|
|
13
17
|
|
|
14
|
-
const binTo = join(camino, '..', `bin/${name}`);
|
|
15
|
-
|
|
16
18
|
const ext = extname(url);
|
|
17
19
|
|
|
18
|
-
if (ext === '.tgz')
|
|
20
|
+
if (ext === '.tgz' || ext === '.gz')
|
|
19
21
|
commands.push(...unpack(letra));
|
|
20
22
|
|
|
21
23
|
if (!ext || ext === '.sh')
|
|
22
24
|
commands.push(...execute(letra));
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
commands.push(...createSymlinks({
|
|
27
|
+
camino,
|
|
28
|
+
name,
|
|
29
|
+
bin,
|
|
30
|
+
}));
|
|
26
31
|
|
|
27
32
|
return commands;
|
|
28
33
|
};
|
|
34
|
+
|
|
35
|
+
function createSymlinks({camino, name, bin}) {
|
|
36
|
+
const commands = [];
|
|
37
|
+
const parsedBin = parseBin(name, bin);
|
|
38
|
+
|
|
39
|
+
for (const [name, from] of entries(parsedBin)) {
|
|
40
|
+
const binFrom = join(camino, from);
|
|
41
|
+
const binTo = join(camino, '..', `bin/${name}`);
|
|
42
|
+
|
|
43
|
+
commands.push(`ln -fs ${binFrom} ${binTo}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return commands;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function parseBin(name, bin) {
|
|
50
|
+
if (isString(bin))
|
|
51
|
+
return {
|
|
52
|
+
[name]: `${name}/${bin}`,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return bin;
|
|
56
|
+
}
|
package/lib/parser/unpack.js
CHANGED
|
@@ -13,11 +13,10 @@ export const unpack = (letra) => {
|
|
|
13
13
|
const filename = basename(renderedurl);
|
|
14
14
|
|
|
15
15
|
commands.push(`wget ${renderedurl}`);
|
|
16
|
-
commands.push(`tar zxf ${filename}`);
|
|
17
|
-
commands.push(`rm ${filename}`);
|
|
18
|
-
commands.push(`mkdir -p ${camino}`);
|
|
19
16
|
commands.push(`rm -rf ${camino}/${name}`);
|
|
20
|
-
commands.push(`
|
|
17
|
+
commands.push(`mkdir -p ${camino}/${name}`);
|
|
18
|
+
commands.push(`tar zxf ${filename} -C ${camino}/${name}`);
|
|
19
|
+
commands.push(`rm ${filename}`);
|
|
21
20
|
|
|
22
21
|
return commands;
|
|
23
22
|
};
|