サンプル
fs-extra 8.1.0: remove
検証済みサンプル — npm fs-extra 8.1.0: remove. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: fs.remove asynchronously deletes a single file
sha256:59d0c4c6e383bdc4814ee7b5bfae6da9300f24dadf3c33e87c18c14238b869a7
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-23 |
ケース
HOW- ゴール
- verify fs-extra.remove in pkg:npm/fs-extra@8.1.0
- パッケージ
- シンボル
-
- fs-extra.remove
- 環境
- node 22.23.2
- 作成日
- 2026-08-23T04:46:28Z
コントラクト
- fs.remove asynchronously deletes a single file
- fs.remove asynchronously deletes a non-empty nested directory hierarchy recursively
- fs.remove resolves without error when the target path does not exist
- fs.remove removes a symbolic link without deleting the underlying target
- fs.removeSync synchronously removes files and directories without throwing on non-existent paths
ファイル
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
ソース
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify fs-extra.remove in pkg:npm/fs-extra@8.1.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/fs-extra@8.1.0
Demonstrate these symbols/APIs:
- fs-extra.remove
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:038c72d32c186d5c05d099a565de1da0d3db833fae6d1e86df8b9d8b976aedac","constraints":{"executionContext":"node"},"contract":["fs.remove asynchronously deletes a single file","fs.remove asynchronously deletes a non-empty nested directory hierarchy recursively","fs.remove resolves without error when the target path does not exist","fs.remove removes a symbolic link without deleting the underlying target","fs.removeSync synchronously removes files and directories without throwing on non-existent paths"],"goal":"verify fs-extra.remove in pkg:npm/fs-extra@8.1.0","kind":"HOW","packages":["pkg:npm/fs-extra@8.1.0"],"schemaVersion":1,"symbols":["fs-extra.remove"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/fs-extra@8.1.0"],"schemaVersion":1,"subject":"pkg:npm/fs-extra@8.1.0","symbols":["fs-extra.remove"],"verifierAdapter":"node-typescript@1"}
const fs = require('fs-extra');
/**
* Asynchronously removes a file or directory.
* @param {string} targetPath - Path to file or directory to remove.
* @returns {Promise<void>}
*/
async function removePath(targetPath) {
await fs.remove(targetPath);
}
/**
* Synchronously removes a file or directory.
* @param {string} targetPath - Path to file or directory to remove.
*/
function removePathSync(targetPath) {
fs.removeSync(targetPath);
}
/**
* Removes target and verifies it no longer exists.
* @param {string} targetPath
* @returns {Promise<boolean>} - True if removal succeeded and path no longer exists.
*/
async function safeClean(targetPath) {
await fs.remove(targetPath);
return !(await fs.pathExists(targetPath));
}
module.exports = {
fs,
removePath,
removePathSync,
safeClean
};
{
"name": "sample-fs-extra-remove",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-fs-extra-remove",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"fs-extra": "8.1.0"
}
},
"node_modules/fs-extra": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz",
"integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==",
"license": "MIT",
"dependencies": {
"graceful-fs": "^4.2.0",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
},
"engines": {
"node": ">=6 <7 || >=8"
}
},
"node_modules/graceful-fs": {
"version": "4.2.11",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
"license": "ISC"
},
"node_modules/jsonfile": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
"integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==",
"license": "MIT",
"optionalDependencies": {
"graceful-fs": "^4.1.6"
}
},
"node_modules/universalify": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==",
"license": "MIT",
"engines": {
"node": ">= 4.0.0"
}
}
}
}
{
"name": "sample-fs-extra-remove",
"version": "1.0.0",
"description": "Minimal sample verifying fs-extra.remove in pkg:npm/fs-extra@8.1.0",
"main": "index.js",
"scripts": {
"test": "node test/contract.mjs"
},
"license": "MIT-0",
"dependencies": {
"fs-extra": "8.1.0"
}
}
{
"schemaVersion": 1,
"goal": "verify fs-extra.remove in pkg:npm/fs-extra@8.1.0",
"kind": "HOW",
"packages": [
"pkg:npm/fs-extra@8.1.0"
],
"symbols": [
"fs-extra.remove"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
import assert from 'node:assert';
import path from 'node:path';
import os from 'node:os';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const { fs, removePath, removePathSync, safeClean } = require('../index.js');
async function runContract() {
const tmpBase = path.join(os.tmpdir(), `csx-contract-fs-remove-${Date.now()}-${Math.random().toString(36).slice(2)}`);
await fs.ensureDir(tmpBase);
try {
// 1. fs.remove asynchronously deletes a single file
const singleFilePath = path.join(tmpBase, 'single-file.txt');
await fs.outputFile(singleFilePath, 'file content to delete', 'utf8');
assert.strictEqual(await fs.pathExists(singleFilePath), true, 'File should exist before removal');
await removePath(singleFilePath);
assert.strictEqual(await fs.pathExists(singleFilePath), false, 'File should not exist after remove');
// 2. fs.remove asynchronously deletes a non-empty nested directory hierarchy recursively
const nestedDir = path.join(tmpBase, 'nested', 'level1', 'level2');
const nestedFile1 = path.join(nestedDir, 'file1.json');
const nestedFile2 = path.join(tmpBase, 'nested', 'level1', 'file2.txt');
await fs.outputJson(nestedFile1, { key: 'value' });
await fs.outputFile(nestedFile2, 'level1 data', 'utf8');
assert.strictEqual(await fs.pathExists(nestedDir), true, 'Nested directory should exist');
assert.strictEqual(await fs.pathExists(nestedFile1), true, 'Nested file1 should exist');
assert.strictEqual(await fs.pathExists(nestedFile2), true, 'Nested file2 should exist');
const topNestedDir = path.join(tmpBase, 'nested');
await removePath(topNestedDir);
assert.strictEqual(await fs.pathExists(topNestedDir), false, 'Top nested dir should not exist after remove');
assert.strictEqual(await fs.pathExists(nestedFile1), false, 'Nested file1 should not exist');
assert.strictEqual(await fs.pathExists(nestedFile2), false, 'Nested file2 should not exist');
// 3. fs.remove resolves without error when the target path does not exist
const nonExistentPath = path.join(tmpBase, 'does-not-exist-xyz-98765');
assert.strictEqual(await fs.pathExists(nonExistentPath), false);
await assert.doesNotReject(async () => {
await removePath(nonExistentPath);
}, 'remove on non-existent path must not throw/reject');
// 4. fs.remove removes a symbolic link without deleting the underlying target
const targetFile = path.join(tmpBase, 'real-target.txt');
const symlinkPath = path.join(tmpBase, 'symlink-to-target.txt');
await fs.outputFile(targetFile, 'preserved real file content', 'utf8');
await fs.ensureSymlink(targetFile, symlinkPath);
assert.strictEqual(await fs.pathExists(symlinkPath), true, 'Symlink should exist');
assert.strictEqual(await fs.pathExists(targetFile), true, 'Target file should exist');
await removePath(symlinkPath);
assert.strictEqual(await fs.pathExists(symlinkPath), false, 'Symlink should be removed');
assert.strictEqual(await fs.pathExists(targetFile), true, 'Target file must still exist after symlink removal');
const contentAfter = await fs.readFile(targetFile, 'utf8');
assert.strictEqual(contentAfter, 'preserved real file content', 'Target content must remain intact');
// 5. fs.removeSync synchronously removes files and directories without throwing on non-existent paths
const syncDir = path.join(tmpBase, 'sync-tree');
const syncFile = path.join(syncDir, 'child.txt');
await fs.outputFile(syncFile, 'sync content', 'utf8');
assert.strictEqual(await fs.pathExists(syncFile), true);
removePathSync(syncFile);
assert.strictEqual(await fs.pathExists(syncFile), false, 'File must be removed by removeSync');
removePathSync(syncDir);
assert.strictEqual(await fs.pathExists(syncDir), false, 'Directory must be removed by removeSync');
assert.doesNotThrow(() => {
removePathSync(path.join(tmpBase, 'sync-non-existent-12345'));
}, 'removeSync on missing path must not throw');
// 6. safeClean helper verification
const cleanDir = path.join(tmpBase, 'safe-clean-dir');
await fs.outputFile(path.join(cleanDir, 'temp.log'), 'temp log');
const cleaned = await safeClean(cleanDir);
assert.strictEqual(cleaned, true, 'safeClean must return true when target is removed');
assert.strictEqual(await fs.pathExists(cleanDir), false);
console.log('fs-extra.remove contract tests passed successfully.');
} finally {
if (await fs.pathExists(tmpBase)) {
await fs.remove(tmpBase);
}
}
}
runContract().catch((err) => {
console.error('fs-extra.remove contract test failed:', err);
process.exit(1);
});
オリジンシーダー
匿名