Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade level from 6.0.1 to 8.0.0 for m1 mac compatibility #531

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/leveldb-store/package.json
Expand Up @@ -36,7 +36,7 @@
"@jscpd/core": "^3.4.5",
"@jscpd/tokenizer": "^3.4.5",
"fs-extra": "^9.0.0",
"level": "^6.0.1",
"level": "^8.0.0",
"rimraf": "^3.0.2"
},
"devDependencies": {
Expand Down
12 changes: 6 additions & 6 deletions packages/leveldb-store/src/index.ts
Expand Up @@ -2,13 +2,11 @@ import {IStore} from '@jscpd/core';
import {IMapFrame} from '@jscpd/tokenizer';
import {ensureDirSync} from 'fs-extra';
import * as rimraf from 'rimraf';

const level = require('level');
import {Level} from 'level';

export default class LevelDbStore implements IStore<IMapFrame> {
private name: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
private dbs: Record<string, any> = {};
private dbs: Record<string, Level> = {};

get(key: string): Promise<IMapFrame> {
return this.dbs[this.name].get(key).then((value: string) => JSON.parse(value));
Expand All @@ -20,12 +18,14 @@ export default class LevelDbStore implements IStore<IMapFrame> {
const path = `.jscpd/${name}`;
rimraf.sync(path);
ensureDirSync(path);
this.dbs[name] = level(path);
this.dbs[name] = new Level(path);
}
}

set(key: string, value: IMapFrame): Promise<IMapFrame> {
return this.dbs[this.name].put(key, JSON.stringify(value));
return this.dbs[this.name]
.put(key, JSON.stringify(value))
.then(() => value);
}

close(): void {
Expand Down
3 changes: 2 additions & 1 deletion packages/tsconfig.build.json
Expand Up @@ -3,7 +3,8 @@
"module": "commonjs",
"target": "es2015",
"declaration": true,
"sourceMap": true
"sourceMap": true,
"skipLibCheck": true
},
"exclude": [
"node_modules",
Expand Down