@zenfs/devel 0.0.0-stage → 0.0.1

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.
Files changed (52) hide show
  1. package/LICENSE.md +157 -0
  2. package/README.md +46 -2
  3. package/dist/bin/make-index.d.ts +2 -0
  4. package/dist/bin/make-index.js +110 -0
  5. package/dist/bin/zci.d.ts +2 -0
  6. package/dist/bin/zci.js +51 -0
  7. package/dist/bin/zenfs-test.d.ts +2 -0
  8. package/dist/bin/zenfs-test.js +242 -0
  9. package/dist/ci.d.ts +15 -0
  10. package/dist/ci.js +74 -0
  11. package/dist/tests/common.d.ts +28 -0
  12. package/dist/tests/common.js +37 -0
  13. package/dist/tests/logs.d.ts +1 -0
  14. package/dist/tests/logs.js +21 -0
  15. package/dist/tests/setup.d.ts +9 -0
  16. package/dist/tests/setup.js +40 -0
  17. package/eslint.shared.js +60 -0
  18. package/package.json +91 -5
  19. package/tests/data/49chars.txt +1 -0
  20. package/tests/data/a.js +46 -0
  21. package/tests/data/a1.js +46 -0
  22. package/tests/data/elipses.txt +1 -0
  23. package/tests/data/empty.txt +0 -0
  24. package/tests/data/exit.js +22 -0
  25. package/tests/data/image.jpg +0 -0
  26. package/tests/data/utf8.txt +1 -0
  27. package/tests/data/x.txt +1 -0
  28. package/tests/data-license.md +19 -0
  29. package/tests/fs/append.test.ts +34 -0
  30. package/tests/fs/concurrency.test.ts +113 -0
  31. package/tests/fs/dir.test.ts +103 -0
  32. package/tests/fs/directory.test.ts +189 -0
  33. package/tests/fs/errors.test.ts +159 -0
  34. package/tests/fs/exists.test.ts +23 -0
  35. package/tests/fs/links.test.ts +308 -0
  36. package/tests/fs/open.test.ts +23 -0
  37. package/tests/fs/permissions.test.ts +344 -0
  38. package/tests/fs/read.test.ts +94 -0
  39. package/tests/fs/readFile.test.ts +58 -0
  40. package/tests/fs/rename.test.ts +93 -0
  41. package/tests/fs/scaling.test.ts +35 -0
  42. package/tests/fs/stat.test.ts +115 -0
  43. package/tests/fs/streams.test.ts +204 -0
  44. package/tests/fs/tempdir.test.ts +64 -0
  45. package/tests/fs/times.test.ts +85 -0
  46. package/tests/fs/truncate.test.ts +89 -0
  47. package/tests/fs/watch.test.ts +246 -0
  48. package/tests/fs/write.test.ts +118 -0
  49. package/tests/fs/xattr.test.ts +96 -0
  50. package/tests/readme.md +5 -0
  51. package/tests/setup/memory.ts +3 -0
  52. package/tests/tsconfig.json +8 -0
package/dist/ci.js ADDED
@@ -0,0 +1,74 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-or-later
2
+ import { Octokit } from '@octokit/action';
3
+ import { mkdirSync } from 'node:fs';
4
+ import { join } from 'node:path/posix';
5
+ import { _throw } from 'utilium';
6
+ import { JSONFileMap } from 'utilium/fs';
7
+ const octokit = new Octokit();
8
+ const [owner, repo] = process.env.GITHUB_REPOSITORY?.split('/') || _throw('GITHUB_REPOSITORY is not set');
9
+ const head_sha = process.env.GITHUB_SHA || _throw('GITHUB_SHA is not set');
10
+ mkdirSync(join(import.meta.dirname, '../tmp'), { recursive: true });
11
+ const checks = new JSONFileMap(join(import.meta.dirname, '../tmp/checks.json'), { overwrite_invalid: true });
12
+ /** Maps test names and shortcuts to full check names */
13
+ export const checkNames = {
14
+ // Basic ones
15
+ format: 'Formatting',
16
+ lint: 'Linting',
17
+ build: 'Build',
18
+ license: 'SDPX License Check',
19
+ // Tests
20
+ 'Common tests': 'Unit tests: common',
21
+ memory: 'Unit tests: InMemory',
22
+ context: 'Unit tests: contexts',
23
+ index: 'Unit tests: Index',
24
+ port: 'Unit tests: Port',
25
+ fetch: 'Unit tests: Fetch',
26
+ cow: 'Unit tests: Copy-On-Write',
27
+ 'single-buffer': 'Unit tests: SingleBuffer',
28
+ };
29
+ /**
30
+ * Create a new GitHub check run
31
+ */
32
+ export async function createCheck(id, name) {
33
+ const response = await octokit.request('POST /repos/{owner}/{repo}/check-runs', {
34
+ owner,
35
+ repo,
36
+ name,
37
+ head_sha,
38
+ status: 'queued',
39
+ started_at: new Date().toISOString(),
40
+ });
41
+ checks.set(id, { id: Number(response.data.id), completed: false });
42
+ }
43
+ /**
44
+ * Move an existing check run from "queued" to "in_progress".
45
+ */
46
+ export async function startCheck(id) {
47
+ const check = checks.get(id);
48
+ await octokit.request('PATCH /repos/{owner}/{repo}/check-runs/{check_run_id}', {
49
+ owner,
50
+ repo,
51
+ check_run_id: check.id,
52
+ status: 'in_progress',
53
+ started_at: new Date().toISOString(),
54
+ });
55
+ }
56
+ /**
57
+ * Complete a check run
58
+ */
59
+ export async function completeCheck(id, conclusion, title = '', summary = '') {
60
+ const check = checks.get(id);
61
+ if (check.completed)
62
+ return;
63
+ await octokit.request('PATCH /repos/{owner}/{repo}/check-runs/{check_run_id}', {
64
+ owner,
65
+ repo,
66
+ check_run_id: check.id,
67
+ status: 'completed',
68
+ completed_at: new Date().toISOString(),
69
+ conclusion,
70
+ output: { title, summary },
71
+ });
72
+ check.completed = true;
73
+ checks.set(id, check);
74
+ }
@@ -0,0 +1,28 @@
1
+ import { fs as defaultFS } from '@zenfs/core';
2
+ export declare const fs: typeof defaultFS;
3
+ /**
4
+ * A feature or function a backend may not support.
5
+ * Tests that need one are skipped when the backend under test does not have it.
6
+ */
7
+ export type TestFlag = 'sync' | 'async' | 'write' | 'appends' | 'directories' | 'links' | 'symlinks' | 'rename' | 'truncate' | 'streams' | 'watch' | 'permissions' | 'xattr' | 'times' | 'tempdir' | 'lchmod' | 'promises.exists' | 'root';
8
+ /**
9
+ * Whether a backend supports a flag.
10
+ *
11
+ * `false` is for things a backend can not support, while `'skip'` is for temporarily disabling something.
12
+ * `'todo'` is for things that should work but don't yet.
13
+ */
14
+ export type TestFlagState = boolean | 'skip' | 'todo';
15
+ /** Options for `suite` and `test`. Note this is a subset of both, since they do not share a type. */
16
+ export interface TestConfig {
17
+ skip?: string;
18
+ todo?: string;
19
+ }
20
+ /**
21
+ * Configures a `suite` or `test` to run only if the backend supports all of the given flags.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * test('lchmod', config('lchmod', 'async'), async () => { ... });
26
+ * ```
27
+ */
28
+ export declare function config(...required: TestFlag[]): TestConfig;
@@ -0,0 +1,37 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-or-later
2
+ import { fs as defaultFS } from '@zenfs/core';
3
+ import { join, resolve } from 'node:path';
4
+ import { styleText } from 'node:util';
5
+ import { setupLogs } from './logs.js';
6
+ setupLogs();
7
+ const setupPath = resolve(process.env.SETUP || join(import.meta.dirname, '../../tests/setup/memory.ts'));
8
+ process.on('unhandledRejection', (reason) => {
9
+ console.error('Unhandled rejection:', styleText('red', reason.stack || reason.message));
10
+ });
11
+ const setup = await import(setupPath).catch(error => {
12
+ console.log('Failed to import test setup:');
13
+ throw error;
14
+ });
15
+ // Satisfies is used to make sure that ZenFS is fully type compatible with Node.js
16
+ export const fs = (setup.fs || defaultFS);
17
+ /** Flags are supported unless the setup says otherwise */
18
+ const flags = (setup.flags ?? {});
19
+ /**
20
+ * Configures a `suite` or `test` to run only if the backend supports all of the given flags.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * test('lchmod', config('lchmod', 'async'), async () => { ... });
25
+ * ```
26
+ */
27
+ export function config(...required) {
28
+ for (const flag of required) {
29
+ const state = flags[flag] ?? true;
30
+ if (state === true)
31
+ continue;
32
+ if (state == 'todo')
33
+ return { todo: `${flag} is not implemented yet` };
34
+ return { skip: state == 'skip' ? `${flag} is temporarily skipped` : `${flag} is not supported` };
35
+ }
36
+ return {};
37
+ }
@@ -0,0 +1 @@
1
+ export declare function setupLogs(prefix?: string): void;
@@ -0,0 +1,21 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-or-later
2
+ import { log } from 'kerium';
3
+ export function setupLogs(prefix) {
4
+ const { ZENFS_LOG_LEVEL } = process.env;
5
+ let level = log.Level.ERR;
6
+ if (ZENFS_LOG_LEVEL) {
7
+ const tmp = parseInt(ZENFS_LOG_LEVEL);
8
+ if (Number.isSafeInteger(tmp))
9
+ level = tmp;
10
+ else
11
+ level = ZENFS_LOG_LEVEL;
12
+ }
13
+ log.configure({
14
+ enabled: true,
15
+ format: log.fancy({ style: 'ansi', colorize: 'message' }),
16
+ dumpBacklog: true,
17
+ level,
18
+ stack: true,
19
+ output: (...msg) => (prefix ? console.error(prefix, ...msg) : console.error(...msg)),
20
+ });
21
+ }
@@ -0,0 +1,9 @@
1
+ import type { NodeFS } from '@zenfs/core/node/types';
2
+ export declare const data: string;
3
+ export declare const tmp: string;
4
+ export declare function copyAsync(_path: string, fs?: NodeFS): Promise<void>;
5
+ export declare function copySync(_path: string, fs?: NodeFS): void;
6
+ /**
7
+ * @deprecated @hidden
8
+ */
9
+ export declare const copy: typeof copySync;
@@ -0,0 +1,40 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-or-later
2
+ import { fs as _fs } from '@zenfs/core';
3
+ import { existsSync, mkdirSync, readFileSync, readdirSync, statSync } from 'node:fs';
4
+ import { join, relative } from 'node:path';
5
+ export const data = join(import.meta.dirname, '../../tests/data');
6
+ export const tmp = join(import.meta.dirname, '../../tests/tmp');
7
+ if (!existsSync(tmp))
8
+ mkdirSync(tmp, { recursive: true });
9
+ export async function copyAsync(_path, fs = _fs) {
10
+ const path = relative(data, _path) || '/';
11
+ const stats = statSync(_path);
12
+ if (!stats.isDirectory()) {
13
+ await fs.promises.writeFile(path, readFileSync(_path));
14
+ return;
15
+ }
16
+ if (path != '/') {
17
+ await fs.promises.mkdir(path);
18
+ }
19
+ for (const file of readdirSync(_path)) {
20
+ await copyAsync(join(_path, file), fs);
21
+ }
22
+ }
23
+ export function copySync(_path, fs = _fs) {
24
+ const path = relative(data, _path) || '/';
25
+ const stats = statSync(_path);
26
+ if (!stats.isDirectory()) {
27
+ fs.writeFileSync(path, readFileSync(_path));
28
+ return;
29
+ }
30
+ if (path != '/') {
31
+ fs.mkdirSync(path);
32
+ }
33
+ for (const file of readdirSync(_path)) {
34
+ copySync(join(_path, file), fs);
35
+ }
36
+ }
37
+ /**
38
+ * @deprecated @hidden
39
+ */
40
+ export const copy = copySync;
@@ -0,0 +1,60 @@
1
+ /* Shared eslint rules */
2
+ import eslint from '@eslint/js';
3
+ import globals from 'globals';
4
+ import { configs } from 'typescript-eslint';
5
+
6
+ export default [
7
+ {
8
+ name: 'ZenFS',
9
+ extends: [eslint.configs.recommended, ...configs.recommendedTypeChecked],
10
+ files: ['src/**/*.ts', 'tests/**/*.ts'],
11
+ languageOptions: {
12
+ globals: { ...globals.browser, ...globals.node },
13
+ ecmaVersion: 'latest',
14
+ sourceType: 'module',
15
+ },
16
+ rules: {
17
+ 'no-useless-escape': 'warn',
18
+ 'no-unreachable': 'warn',
19
+ 'no-fallthrough': 'warn',
20
+ 'no-empty': 'warn',
21
+ 'no-case-declarations': 'warn',
22
+ 'prefer-const': 'warn',
23
+ 'prefer-rest-params': 'warn',
24
+ 'prefer-spread': 'warn',
25
+ 'no-unused-vars': 'off',
26
+ '@typescript-eslint/no-unused-vars': ['warn', { varsIgnorePattern: '^_', argsIgnorePattern: '^_' }],
27
+ '@typescript-eslint/no-inferrable-types': 'off',
28
+ '@typescript-eslint/no-this-alias': 'off',
29
+ '@typescript-eslint/no-unsafe-function-type': 'warn',
30
+ '@typescript-eslint/no-wrapper-object-types': 'warn',
31
+ '@typescript-eslint/triple-slash-reference': 'warn',
32
+ '@typescript-eslint/no-non-null-assertion': 'off',
33
+ '@typescript-eslint/no-namespace': 'warn',
34
+ '@typescript-eslint/prefer-as-const': 'warn',
35
+ '@typescript-eslint/no-explicit-any': 'warn',
36
+ '@typescript-eslint/consistent-type-assertions': 'warn',
37
+ '@typescript-eslint/consistent-type-imports': 'warn',
38
+ '@typescript-eslint/no-unnecessary-type-assertion': 'warn',
39
+ '@typescript-eslint/require-await': 'warn',
40
+ '@typescript-eslint/no-unsafe-member-access': 'off',
41
+ '@typescript-eslint/no-unsafe-argument': 'off',
42
+ '@typescript-eslint/no-unsafe-assignment': 'off',
43
+ '@typescript-eslint/no-unsafe-return': 'off',
44
+ '@typescript-eslint/no-redundant-type-constituents': 'warn',
45
+ '@typescript-eslint/no-unsafe-call': 'off',
46
+ '@typescript-eslint/restrict-plus-operands': 'off',
47
+ '@typescript-eslint/no-base-to-string': 'off',
48
+ '@typescript-eslint/no-unused-expressions': 'warn',
49
+ '@typescript-eslint/no-empty-object-type': 'off',
50
+ },
51
+ },
52
+ {
53
+ name: 'Tests overrides',
54
+ files: ['tests/**/*.ts'],
55
+ rules: {
56
+ '@typescript-eslint/no-floating-promises': 'off',
57
+ '@typescript-eslint/no-explicit-any': 'off',
58
+ },
59
+ },
60
+ ];
package/package.json CHANGED
@@ -1,6 +1,92 @@
1
1
  {
2
- "name": "@zenfs/devel",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@zenfs/devel",
3
+ "version": "0.0.1",
4
+ "description": "Tooling for developing ZenFS packages",
5
+ "funding": {
6
+ "type": "individual",
7
+ "url": "https://github.com/sponsors/james-pre"
8
+ },
9
+ "keywords": [
10
+ "zenfs",
11
+ "filesystem",
12
+ "testing",
13
+ "eslint"
14
+ ],
15
+ "bin": {
16
+ "make-index": "dist/bin/make-index.js",
17
+ "zenfs-test": "dist/bin/zenfs-test.js",
18
+ "zci": "dist/bin/zci.js"
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "tests",
23
+ "eslint.shared.js"
24
+ ],
25
+ "type": "module",
26
+ "homepage": "https://github.com/zen-fs/devel",
27
+ "author": "James Prevett <jp@jamespre.dev> (https://jamespre.dev)",
28
+ "license": "LGPL-3.0-or-later",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/zen-fs/devel.git"
32
+ },
33
+ "bugs": {
34
+ "url": "https://github.com/zen-fs/devel/issues"
35
+ },
36
+ "engines": {
37
+ "node": ">= 22"
38
+ },
39
+ "exports": {
40
+ "./eslint": "./eslint.shared.js",
41
+ "./*": "./dist/*.js"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public",
45
+ "provenance": true
46
+ },
47
+ "scripts": {
48
+ "format": "prettier --write .",
49
+ "format:check": "prettier --check .",
50
+ "spdx:check": "npx lice -a src tests/**/*.test.ts",
51
+ "spdx:fix": "npx lice -aw src tests/**/*.test.ts",
52
+ "lint": "eslint src tests",
53
+ "build": "tsc --build",
54
+ "dev": "tsc --build --watch",
55
+ "test": "node dist/bin/zenfs-test.js tests/setup/memory.ts",
56
+ "prepublishOnly": "npm run build"
57
+ },
58
+ "dependencies": {
59
+ "@eslint/js": "^10.0.1",
60
+ "@octokit/action": "^8.0.4",
61
+ "buffer": "^6.0.3",
62
+ "c8": "^12.0.0",
63
+ "globals": "^17.3.0",
64
+ "kerium": "^1.5.0",
65
+ "typescript-eslint": "^8.58.0",
66
+ "utilium": "^3.7.0"
67
+ },
68
+ "peerDependencies": {
69
+ "@zenfs/core": "^2.8.0",
70
+ "eslint": "^10.1.0"
71
+ },
72
+ "peerDependenciesMeta": {
73
+ "eslint": {
74
+ "optional": true
75
+ }
76
+ },
77
+ "devDependencies": {
78
+ "@types/node": "^26.0.0",
79
+ "@zenfs/core": "^2.8.0",
80
+ "eslint": "^10.1.0",
81
+ "prettier": "^3.2.5",
82
+ "typescript": "^6.0.0"
83
+ },
84
+ "prettier": {
85
+ "singleQuote": true,
86
+ "useTabs": true,
87
+ "tabWidth": 4,
88
+ "printWidth": 150,
89
+ "arrowParens": "avoid",
90
+ "experimentalOperatorPosition": "start"
91
+ }
92
+ }
@@ -0,0 +1 @@
1
+ 0123456789abcdef0123456789abcdef0123456789abcdef
@@ -0,0 +1,46 @@
1
+ // Copyright Joyent, Inc. and other Node contributors.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a
4
+ // copy of this software and associated documentation files (the
5
+ // "Software"), to deal in the Software without restriction, including
6
+ // without limitation the rights to use, copy, modify, merge, publish,
7
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
8
+ // persons to whom the Software is furnished to do so, subject to the
9
+ // following conditions:
10
+ //
11
+ // The above copyright notice and this permission notice shall be included
12
+ // in all copies or substantial portions of the Software.
13
+ //
14
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ var c = require('./b/c');
23
+
24
+ console.error('load fixtures/a.js');
25
+
26
+ var string = 'A';
27
+
28
+ exports.SomeClass = c.SomeClass;
29
+
30
+ exports.A = function () {
31
+ return string;
32
+ };
33
+
34
+ exports.C = function () {
35
+ return c.C();
36
+ };
37
+
38
+ exports.D = function () {
39
+ return c.D();
40
+ };
41
+
42
+ exports.number = 42;
43
+
44
+ process.on('exit', function () {
45
+ string = 'A done';
46
+ });
@@ -0,0 +1,46 @@
1
+ // Copyright Joyent, Inc. and other Node contributors.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a
4
+ // copy of this software and associated documentation files (the
5
+ // "Software"), to deal in the Software without restriction, including
6
+ // without limitation the rights to use, copy, modify, merge, publish,
7
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
8
+ // persons to whom the Software is furnished to do so, subject to the
9
+ // following conditions:
10
+ //
11
+ // The above copyright notice and this permission notice shall be included
12
+ // in all copies or substantial portions of the Software.
13
+ //
14
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ var c = require('./b/c');
23
+
24
+ console.error('load fixtures/a.js');
25
+
26
+ var string = 'A';
27
+
28
+ exports.SomeClass = c.SomeClass;
29
+
30
+ exports.A = function () {
31
+ return string;
32
+ };
33
+
34
+ exports.C = function () {
35
+ return c.C();
36
+ };
37
+
38
+ exports.D = function () {
39
+ return c.D();
40
+ };
41
+
42
+ exports.number = 42;
43
+
44
+ process.on('exit', function () {
45
+ string = 'A done';
46
+ });
@@ -0,0 +1 @@
1
+ …………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………
File without changes
@@ -0,0 +1,22 @@
1
+ // Copyright Joyent, Inc. and other Node contributors.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a
4
+ // copy of this software and associated documentation files (the
5
+ // "Software"), to deal in the Software without restriction, including
6
+ // without limitation the rights to use, copy, modify, merge, publish,
7
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
8
+ // persons to whom the Software is furnished to do so, subject to the
9
+ // following conditions:
10
+ //
11
+ // The above copyright notice and this permission notice shall be included
12
+ // in all copies or substantial portions of the Software.
13
+ //
14
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ process.exit(process.argv[2] || 1);
Binary file
@@ -0,0 +1 @@
1
+ 南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,疆域包括今天中国的广东、广西两省区的大部份地区,福建省、湖南、贵州、云南的一小部份地区和越南的北部。南越国是秦朝灭亡后,由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。前196年和前179年,南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。南越国共存在93年,历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、经济现状。
@@ -0,0 +1 @@
1
+ xyz
@@ -0,0 +1,19 @@
1
+ Copyright (c) Joyent, Inc. and other Node contributors for `test/data`.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,34 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-or-later
2
+ import assert from 'node:assert/strict';
3
+ import { suite, test } from 'node:test';
4
+ import { fs, config } from '@zenfs/devel/tests/common';
5
+
6
+ const content = 'Sample content',
7
+ original = 'ABCD';
8
+
9
+ suite('Appends', config('appends'), () => {
10
+ test('Create an empty file and add content', config('async'), async () => {
11
+ const filename = 'append.txt';
12
+ await fs.promises.appendFile(filename, content);
13
+ const data = await fs.promises.readFile(filename, 'utf8');
14
+ assert.equal(data, content);
15
+ });
16
+
17
+ test('Append data to a non-empty file', config('async'), async () => {
18
+ const filename = 'append2.txt';
19
+
20
+ await fs.promises.writeFile(filename, original);
21
+ await fs.promises.appendFile(filename, content);
22
+ const data = await fs.promises.readFile(filename, 'utf8');
23
+ assert.equal(data, original + content);
24
+ });
25
+
26
+ test('Append a buffer to the file', config('async'), async () => {
27
+ const filename = 'append3.txt';
28
+
29
+ await fs.promises.writeFile(filename, original);
30
+ await fs.promises.appendFile(filename, content);
31
+ const data = await fs.promises.readFile(filename, 'utf8');
32
+ assert.equal(data, original + content);
33
+ });
34
+ });