Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
4349931
scaffold codemod
AugustinMauroy Jul 26, 2025
c4dd3ba
add first draft
AugustinMauroy Jul 26, 2025
b46d7af
fix: typo
AugustinMauroy Jul 27, 2025
9e0365a
refracto to use AST
AugustinMauroy Jul 27, 2025
a4d4938
refracto
AugustinMauroy Jul 27, 2025
aa4a23d
WARNING: edge-case
AugustinMauroy Jul 27, 2025
13c2ddc
WIP
AugustinMauroy Jul 27, 2025
f989d4f
clean chore files
AugustinMauroy Jul 29, 2025
095b88a
improve security
AugustinMauroy Jul 29, 2025
ef62f5c
chore(`codemod.yaml`): use righ file ext + correct scope
AugustinMauroy Jul 29, 2025
b406468
Update workflow.ts
AugustinMauroy Aug 13, 2025
062b329
scaffold codemod
AugustinMauroy Jul 26, 2025
ac59325
add first draft
AugustinMauroy Jul 26, 2025
83c0cf8
fix: typo
AugustinMauroy Jul 27, 2025
7d4665c
refracto to use AST
AugustinMauroy Jul 27, 2025
f4250a1
refracto
AugustinMauroy Jul 27, 2025
8a7741e
WARNING: edge-case
AugustinMauroy Jul 27, 2025
2441b8e
WIP
AugustinMauroy Jul 27, 2025
88e8c25
clean chore files
AugustinMauroy Jul 29, 2025
b84169d
improve security
AugustinMauroy Jul 29, 2025
f631355
chore(`codemod.yaml`): use righ file ext + correct scope
AugustinMauroy Jul 29, 2025
cbf2867
Update workflow.ts
AugustinMauroy Aug 13, 2025
9a52487
Merge branch 'feat(`fs-truncate-fs-depreciation`)' of https://github.…
AugustinMauroy Aug 13, 2025
d2864ff
Update package-lock.json
AugustinMauroy Aug 13, 2025
0745ea3
Merge branch 'main' into feat(`fs-truncate-fs-depreciation`)
AugustinMauroy Aug 17, 2025
48a64f8
Update workflow.ts
AugustinMauroy Sep 19, 2025
0da4e0d
Merge branch 'main' into feat(`fs-truncate-fs-depreciation`)
AugustinMauroy Sep 19, 2025
0cd173d
Update package-lock.json
AugustinMauroy Sep 19, 2025
ca0bd07
update
AugustinMauroy Sep 19, 2025
d286fa9
fix
AugustinMauroy Sep 20, 2025
b193d74
Update workflow.ts
AugustinMauroy Sep 27, 2025
3f1655e
Merge branch 'main' into feat(`fs-truncate-fs-depreciation`)
AugustinMauroy Sep 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 63 additions & 48 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions recipes/fs-truncate-fd-deprecation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# DEP0081: `fs.truncate()` using a file descriptor

This recipe transforms the usage of `fs.truncate()` to `fs.ftruncateSync()` when a file descriptor is used.

See [DEP0081](https://nodejs.org/api/deprecations.html#DEP0081).

## Example

**Before:**
```js
const { truncate, open, close } = require('node:fs');

open('file.txt', 'w', (err, fd) => {
if (err) throw err;
truncate(fd, 10, (err) => {
if (err) throw err;
close(fd, () => {});
});
});
```

**After:**
```js
const { ftruncate, open, close } = require('node:fs');

open('file.txt', 'w', (err, fd) => {
if (err) throw err;
ftruncate(fd, 10, (err) => {
if (err) throw err;
close(fd, () => {});
});
});
```
21 changes: 21 additions & 0 deletions recipes/fs-truncate-fd-deprecation/codemod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
schema_version: "1.0"
name: "@nodejs/fs-truncate-fd-deprecation"
version: 1.0.0
description: Handle DEP0081 via transforming `truncate` to `ftruncateSync` when using a file descriptor.
author: Augustin Mauroy
license: MIT
workflow: workflow.yaml
category: migration

targets:
languages:
- javascript
- typescript

keywords:
- transformation
- migration

registry:
access: public
visibility: public
24 changes: 24 additions & 0 deletions recipes/fs-truncate-fd-deprecation/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@nodejs/fs-truncate-fd-deprecation",
"version": "1.0.0",
"description": "Handle DEP0081 via transforming `truncate` to `ftruncateSync` when using a file descriptor.",
"type": "module",
"scripts": {
"test": "npx codemod@next jssg test -l typescript ./src/workflow.ts ./"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nodejs/userland-migrations.git",
"directory": "recipes/fs-truncate-fd-deprecation",
"bugs": "https://github.com/nodejs/userland-migrations/issues"
},
"author": "Augustin Mauroy",
"license": "MIT",
"homepage": "https://github.com/nodejs/userland-migrations/blob/main/recipes/fs-truncate-fd-deprecation/README.md",
"devDependencies": {
"@codemod.com/jssg-types": "^1.0.3"
},
"dependencies": {
"@nodejs/codemod-utils": "*"
}
}
Loading
Loading