Skip to content

Commit

Permalink
extract: fix newlines at the end of lists in partials
Browse files Browse the repository at this point in the history
This also fixes 'totals' building the correct lists.
  • Loading branch information
ChALkeR committed Apr 15, 2018
1 parent bf9b9b5 commit 7881485
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/commands/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ async function slimAST(ext, outdir, tgz, slim) {
await promiseEvent(out, 'close');
}

async function writeList(file, list) {
await fs.writeFile(file, `${list.join('\n')}\n`);
}

async function partial(tgz, rebuild) {
const file = path.join(config.dir, 'current/', tgz);
const outdir = path.join(config.dir, 'partials/', tgz);
Expand All @@ -152,23 +156,23 @@ async function partial(tgz, rebuild) {
}
files = lines.map(x => x.replace(/[^/]*\//, ''))
.map(x => `${tgz}/${x}`);
await fs.writeFile(path.join(outdir, 'files.txt'), files.join('\n'));
await writeFile(path.join(outdir, 'files.txt'), files);
// TODO: rebuild new extensions on extensions list changes
for (const ext of extensions) {
await fs.writeFile(
await writeFile(
path.join(outdir, `files${ext}.txt`),
files.filter(entry => entry.endsWith(ext)).join('\n')
files.filter(entry => entry.endsWith(ext))
);
}
}

const excluded = await loadExcluded();
const slim = files.filter(entry => !excluded.some(rexp => rexp.test(entry)));
await fs.writeFile(path.join(outdir, 'slim.files.txt'), slim.join('\n'));
await writeFile(path.join(outdir, 'slim.files.txt'), slim);
for (const ext of extensions) {
await fs.writeFile(
await writeList(
path.join(outdir, `slim.files${ext}.txt`),
slim.filter(entry => entry.endsWith(ext)).join('\n')
slim.filter(entry => entry.endsWith(ext))
);
}

Expand Down

0 comments on commit 7881485

Please sign in to comment.