pkg-preper 0.1.0 → 0.1.2
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/lib/pkg-preper.js +15 -19
- package/package.json +4 -4
package/lib/pkg-preper.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
const cacache = require("cacache");
|
|
22
22
|
const Path = require("path");
|
|
23
|
-
const Promise = require("
|
|
23
|
+
const Promise = require("aveazul");
|
|
24
24
|
const PassThrough = require("stream").PassThrough;
|
|
25
25
|
const mississippi = require("mississippi");
|
|
26
26
|
const pipe = Promise.promisify(mississippi.pipe, { context: mississippi });
|
|
@@ -28,12 +28,8 @@ const tar = require("tar");
|
|
|
28
28
|
const packlist = require("npm-packlist");
|
|
29
29
|
const Fs = require("opfs");
|
|
30
30
|
|
|
31
|
-
const readPkgJson = dir => {
|
|
32
|
-
return Fs.readFile(
|
|
33
|
-
Path.join(dir, "package.json")
|
|
34
|
-
.toString()
|
|
35
|
-
.trim()
|
|
36
|
-
).then(JSON.parse);
|
|
31
|
+
const readPkgJson = (dir) => {
|
|
32
|
+
return Fs.readFile(Path.join(dir, "package.json").toString().trim()).then(JSON.parse);
|
|
37
33
|
};
|
|
38
34
|
|
|
39
35
|
class PkgPreper {
|
|
@@ -51,8 +47,8 @@ class PkgPreper {
|
|
|
51
47
|
// .then(() => {
|
|
52
48
|
// return readJson(path.join(dir, "package.json"));
|
|
53
49
|
// })
|
|
54
|
-
.then(pkg => {
|
|
55
|
-
return cacache.tmp.withTmp(this._tmpDir, { tmpPrefix: "packing" }, tmp => {
|
|
50
|
+
.then((pkg) => {
|
|
51
|
+
return cacache.tmp.withTmp(this._tmpDir, { tmpPrefix: "packing" }, (tmp) => {
|
|
56
52
|
const tmpTarget = Path.join(tmp, Path.basename(target));
|
|
57
53
|
|
|
58
54
|
const tarOpt = {
|
|
@@ -63,15 +59,18 @@ class PkgPreper {
|
|
|
63
59
|
// Provide a specific date in the 1980s for the benefit of zip,
|
|
64
60
|
// which is confounded by files dated at the Unix epoch 0.
|
|
65
61
|
mtime: new Date("1985-10-26T08:15:00.000Z"),
|
|
66
|
-
gzip: true
|
|
62
|
+
gzip: true,
|
|
67
63
|
};
|
|
68
64
|
|
|
69
65
|
return Promise.resolve(packlist({ path: dir }))
|
|
70
|
-
.then(files => {
|
|
66
|
+
.then((files) => {
|
|
71
67
|
// NOTE: node-tar does some Magic Stuff depending on prefixes for files
|
|
72
68
|
// specifically with @ signs, so we just neutralize that one
|
|
73
69
|
// and any such future "features" by prepending `./`
|
|
74
|
-
return tar.create(
|
|
70
|
+
return tar.create(
|
|
71
|
+
tarOpt,
|
|
72
|
+
files.map((f) => `./${f}`)
|
|
73
|
+
);
|
|
75
74
|
})
|
|
76
75
|
.tap(() => Fs.rename(tmpTarget, target));
|
|
77
76
|
// .then(() => getContents(pkg, tmpTarget, filename, logIt))
|
|
@@ -91,7 +90,7 @@ class PkgPreper {
|
|
|
91
90
|
const stream = new PassThrough();
|
|
92
91
|
|
|
93
92
|
readPkgJson(dir)
|
|
94
|
-
.then(pkg => {
|
|
93
|
+
.then((pkg) => {
|
|
95
94
|
if (pkg.scripts && pkg.scripts.prepare) {
|
|
96
95
|
return this._installDependencies(
|
|
97
96
|
dir,
|
|
@@ -101,17 +100,14 @@ class PkgPreper {
|
|
|
101
100
|
})
|
|
102
101
|
.tap(() => stream.emit("prepared"))
|
|
103
102
|
.then(() => {
|
|
104
|
-
return cacache.tmp.withTmp(this._tmpDir, { tmpPrefix: "pacote-packing" }, tmp => {
|
|
103
|
+
return cacache.tmp.withTmp(this._tmpDir, { tmpPrefix: "pacote-packing" }, (tmp) => {
|
|
105
104
|
const tmpTar = Path.join(tmp, "package.tgz");
|
|
106
105
|
return this.packDirectory(manifest, dir, tmpTar).then(() => {
|
|
107
|
-
return pipe(
|
|
108
|
-
Fs.createReadStream(tmpTar),
|
|
109
|
-
stream
|
|
110
|
-
);
|
|
106
|
+
return pipe(Fs.createReadStream(tmpTar), stream);
|
|
111
107
|
});
|
|
112
108
|
});
|
|
113
109
|
})
|
|
114
|
-
.catch(err => {
|
|
110
|
+
.catch((err) => {
|
|
115
111
|
stream.emit("error", err);
|
|
116
112
|
});
|
|
117
113
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pkg-preper",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Package Preparer",
|
|
5
5
|
"main": "lib/pkg-preper.js",
|
|
6
6
|
"scripts": {},
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
},
|
|
16
16
|
"license": "Artistic-2.0",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"
|
|
19
|
-
"cacache": "
|
|
18
|
+
"aveazul": "^1.0.2",
|
|
19
|
+
"cacache": "jchip/cacache",
|
|
20
20
|
"mississippi": "^3.0.0",
|
|
21
|
-
"npm-packlist": "
|
|
21
|
+
"npm-packlist": "jchip/npm-packlist",
|
|
22
22
|
"opfs": "^1.0.6",
|
|
23
23
|
"tar": "^4.4.6",
|
|
24
24
|
"visual-exec": "^0.1.0"
|