Skip to content

Commit 7881485

Browse files
committed
extract: fix newlines at the end of lists in partials
This also fixes 'totals' building the correct lists.
1 parent bf9b9b5 commit 7881485

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/commands/extract.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ async function slimAST(ext, outdir, tgz, slim) {
129129
await promiseEvent(out, 'close');
130130
}
131131

132+
async function writeList(file, list) {
133+
await fs.writeFile(file, `${list.join('\n')}\n`);
134+
}
135+
132136
async function partial(tgz, rebuild) {
133137
const file = path.join(config.dir, 'current/', tgz);
134138
const outdir = path.join(config.dir, 'partials/', tgz);
@@ -152,23 +156,23 @@ async function partial(tgz, rebuild) {
152156
}
153157
files = lines.map(x => x.replace(/[^/]*\//, ''))
154158
.map(x => `${tgz}/${x}`);
155-
await fs.writeFile(path.join(outdir, 'files.txt'), files.join('\n'));
159+
await writeFile(path.join(outdir, 'files.txt'), files);
156160
// TODO: rebuild new extensions on extensions list changes
157161
for (const ext of extensions) {
158-
await fs.writeFile(
162+
await writeFile(
159163
path.join(outdir, `files${ext}.txt`),
160-
files.filter(entry => entry.endsWith(ext)).join('\n')
164+
files.filter(entry => entry.endsWith(ext))
161165
);
162166
}
163167
}
164168

165169
const excluded = await loadExcluded();
166170
const slim = files.filter(entry => !excluded.some(rexp => rexp.test(entry)));
167-
await fs.writeFile(path.join(outdir, 'slim.files.txt'), slim.join('\n'));
171+
await writeFile(path.join(outdir, 'slim.files.txt'), slim);
168172
for (const ext of extensions) {
169-
await fs.writeFile(
173+
await writeList(
170174
path.join(outdir, `slim.files${ext}.txt`),
171-
slim.filter(entry => entry.endsWith(ext)).join('\n')
175+
slim.filter(entry => entry.endsWith(ext))
172176
);
173177
}
174178

0 commit comments

Comments
 (0)