Skip to content

Commit

Permalink
Fit submodule to AdminJS dev workspace (#38)
Browse files Browse the repository at this point in the history
* chore: fit submodule to AdminJS dev workspace

* chore: fixed linting
  • Loading branch information
ariansobczak-rst authored Feb 18, 2022
1 parent 8dad188 commit 9844e78
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"license": "MIT",
"scripts": {
"release": "semantic-release",
"build": "yarn tsc",
"build": "tsc",
"clean": "rm -fr build && mkdir build && rm -fr types && mkdir types",
"dev": "yarn clean && tsc --watch",
"test": "TS_NODE_FILES=true mocha -r ts-node/register ./src/**/*.spec.ts",
Expand Down
15 changes: 9 additions & 6 deletions src/features/upload-file/providers/local-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,24 @@ export class LocalProvider extends BaseProvider {

public async upload(file: UploadedFile, key: string): Promise<any> {
const filePath = process.platform === 'win32'
? this.path(key) : this.path(key).slice(1); // adjusting file path according to OS
? this.path(key) : this.path(key).slice(1) // adjusting file path according to OS

await fs.promises.mkdir(path.dirname(filePath), { recursive: true });
await fs.promises.rename(file.path, filePath);
await fs.promises.mkdir(path.dirname(filePath), { recursive: true })
await fs.promises.rename(file.path, filePath)
}

public async delete(key: string, bucket: string): Promise<any> {
await fs.promises.unlink(process.platform === 'win32'
? this.path(key, bucket) : this.path(key, bucket).slice(1)); // adjusting file path according to OS
await fs.promises.unlink(
process.platform === 'win32'
? this.path(key, bucket)
: this.path(key, bucket).slice(1),
) // adjusting file path according to OS
}

// eslint-disable-next-line class-methods-use-this
public path(key: string, bucket?: string): string {
// Windows doesn't requires the '/' in path, while UNIX system does
return process.platform === 'win32' ? `${path.join(bucket || this.bucket, key)}`
: `/${path.join(bucket || this.bucket, key)}`;
: `/${path.join(bucket || this.bucket, key)}`
}
}

0 comments on commit 9844e78

Please sign in to comment.