Skip to content

Commit

Permalink
move path functions from in-memory to common module
Browse files Browse the repository at this point in the history
  • Loading branch information
CordlessWool committed Mar 16, 2024
1 parent b35732e commit 05a62ae
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 5 deletions.
7 changes: 7 additions & 0 deletions adapters/in-memory/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,17 @@
"peerDependencies": {
"@loom-io/core": "workspace:*"
},
"dependencies": {
"@loom-io/common": "workspace:*"
},
"exports": {
".": {
"types": "./dist/exports/lib.d.ts",
"import": "./dist/exports/lib.js"
},
"./internal": {
"types": "./dist/exports/internal.d.ts",
"import": "./dist/exports/internal.js"
}
},
"maintainers": [
Expand Down
6 changes: 3 additions & 3 deletions adapters/in-memory/src/core/adapter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ class UnwrappedAdapter extends Adapter {
return super.createObjectInRoot(name, ref);
}

protected createObject(path: string, ref: MEMORY_TYPE.FILE): MemoryFile;
protected createObject(path: string, ref: MEMORY_TYPE.DIRECTORY): MemoryDirectory;
protected createObject(path: string, ref: MEMORY_TYPE): MemoryObject {
createObject(path: string, ref: MEMORY_TYPE.FILE): MemoryFile;
createObject(path: string, ref: MEMORY_TYPE.DIRECTORY): MemoryDirectory;
createObject(path: string, ref: MEMORY_TYPE): MemoryObject {
if( ref === MEMORY_TYPE.FILE) {
return super.createObject(path, MEMORY_TYPE.FILE);
} else {
Expand Down
2 changes: 1 addition & 1 deletion adapters/in-memory/src/core/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AlreadyExistsException, NotFoundException } from '../exceptions';
import { ObjectDirent } from './object-dirent.js';
import { MEMORY_TYPE, MemoryDirectory, MemoryFile, MemoryObject, MemoryRoot } from '../definitions';
import { isMemoryDirectoryAndMatchNamePrepared } from '../utils/validations';
import { removePresentedAndTrailingSlash, splitTailingPath } from '../utils/path.js';
import { removePresentedAndTrailingSlash, splitTailingPath } from '@loom-io/common';
export class Adapter implements SourceAdapter {

protected storage: MemoryRoot;
Expand Down
2 changes: 1 addition & 1 deletion adapters/in-memory/src/core/source.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Directory, LoomFile } from '@loom-io/core/internal';
import { Adapter } from './adapter';
import { dirname, basename } from 'node:path';
import { splitTailingPath } from '../utils/path';
import { splitTailingPath } from '@loom-io/common';

export const source = async (path: string, Type?: typeof Directory | typeof LoomFile) => {
const adapter = new Adapter();
Expand Down
1 change: 1 addition & 0 deletions adapters/in-memory/src/exports/internal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../core/adapter';
19 changes: 19 additions & 0 deletions packages/common/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@loom-io/common",
"version": "1.0.0",
"description": "",
"main": "dist/index.js",
"scripts": {
"build": "tsc -p tsconfig.json"
},
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
}
},
"keywords": [],
"author": "",
"license": "MIT"
}
1 change: 1 addition & 0 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './path';
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions packages/common/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["./src"]
}

0 comments on commit 05a62ae

Please sign in to comment.