mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-12-04 17:29:32 +01:00
docs: add Japanese README
This commit is contained in:
5 files changed
+1386
-26
No files matched your search
@@ -1,6 +1,7 @@
|
||||
/**
|
||||
* @fileoverview `npm run release` moves README.zh-CN.md aside for the publish, so npmjs.com
|
||||
* renders README.md, and always puts it back (scripts/npm-release.mjs).
|
||||
* @fileoverview `npm run release` moves the translated READMEs (README.zh-CN.md, README.ja.md)
|
||||
* aside for the publish, so npmjs.com renders README.md, and always puts them back
|
||||
* (scripts/npm-release.mjs).
|
||||
*
|
||||
* Port: N/A (no server).
|
||||
*/
|
||||
@@ -8,7 +9,13 @@ import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'no
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { afterEach, describe, expect, it } from 'vitest';
|
||||
import { ASIDE_NAME, HIDDEN_README, publishWithReadmeAside } from '../scripts/npm-release.mjs';
|
||||
import {
|
||||
ASIDE_NAME,
|
||||
HIDDEN_README,
|
||||
HIDDEN_READMES,
|
||||
asideName,
|
||||
publishWithReadmeAside,
|
||||
} from '../scripts/npm-release.mjs';
|
||||
|
||||
const roots: string[] = [];
|
||||
function fixture(): string {
|
||||
@@ -96,6 +103,30 @@ describe('publishWithReadmeAside', () => {
|
||||
expect(existsSync(join(root, HIDDEN_README))).toBe(false);
|
||||
});
|
||||
|
||||
it('hides the Japanese README too and restores every translation after the publish', () => {
|
||||
const root = fixture();
|
||||
writeFileSync(join(root, 'README.ja.md'), 'japanese\n');
|
||||
let present: string[] = [];
|
||||
const code = publishWithReadmeAside({
|
||||
root,
|
||||
log: quiet,
|
||||
publish: () => {
|
||||
present = ['README.md', ...HIDDEN_READMES].filter((name) => existsSync(join(root, name)));
|
||||
return 0;
|
||||
},
|
||||
});
|
||||
expect(code).toBe(0);
|
||||
expect(HIDDEN_READMES).toContain('README.ja.md');
|
||||
expect(present).toEqual(['README.md']);
|
||||
expect(readFileSync(join(root, HIDDEN_README), 'utf8')).toBe('chinese\n');
|
||||
expect(readFileSync(join(root, 'README.ja.md'), 'utf8')).toBe('japanese\n');
|
||||
for (const name of HIDDEN_READMES) expect(existsSync(join(root, asideName(name)))).toBe(false);
|
||||
});
|
||||
|
||||
it('no aside name is one npm treats as a readme', () => {
|
||||
for (const name of HIDDEN_READMES) expect(/^readme/i.test(asideName(name))).toBe(false);
|
||||
});
|
||||
|
||||
it('package.json routes npm run release through the wrapper', () => {
|
||||
const pkg = JSON.parse(readFileSync(join(import.meta.dirname, '..', 'package.json'), 'utf8'));
|
||||
expect(pkg.scripts.release).toBe('node scripts/npm-release.mjs');
|
||||
|
||||
Reference in new issue
Block a user