Skip to content

Commit

Permalink
add rename file function
Browse files Browse the repository at this point in the history
  • Loading branch information
CordlessWool committed Jan 11, 2025
1 parent e8a0b0c commit b8e1a78
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
19 changes: 19 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"mode": "pre",
"tag": "beta",
"initialVersions": {
"@loom-io/fs-sync": "0.13.0",
"@loom-io/in-memory-adapter": "0.12.11",
"@loom-io/minio-s3-adapter": "0.12.11",
"@loom-io/node-filesystem-adapter": "0.12.11",
"@loom-io/converter": "0.12.11",
"@loom-io/common": "1.0.2",
"@loom-io/core": "0.12.11",
"@loom-io/front-matter-converter": "0.12.11",
"@loom-io/json-converter": "0.12.11",
"@loom-io/yaml-converter": "0.12.11",
"@loom-io/interface-tests": "0.12.11",
"@loom-io/test-utils": "0.12.11"
},
"changesets": []
}
2 changes: 1 addition & 1 deletion adapters/fs-sync/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@loom-io/fs-sync",
"version": "0.12.11",
"version": "0.13.0",
"main": "dist/exports/lib.js",
"types": "dist/exports/lib.d.ts",
"author": "Cotton Coding",
Expand Down
9 changes: 9 additions & 0 deletions adapters/fs-sync/src/core/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,15 @@ export const copyFile = (dest: string | Directory | File) => {
});
};

export const renameFile = (newName: string) =>
g((file: File) => {
const newPath = np.resolve(np.dirname(file.path), newName);
fs.renameSync(file.path, newPath);
return {
path: newPath,
};
});

export const moveTo = (dest: string | File | Directory) => {
const destPath = getPath(dest);
return g((base: Directory | File) => {
Expand Down

0 comments on commit b8e1a78

Please sign in to comment.