summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Van Doorn <vandoorn.nick@gmail.com>2019-01-19 21:58:05 -0800
committerNick Van Doorn <vandoorn.nick@gmail.com>2019-01-19 21:58:05 -0800
commite8d64fb823a73d1297d151b4ebd0d05b86c97a0b (patch)
tree2a875c75b6e5270e082c73f5254669090d75990d /src
parent333fa3303788479d5df7b91996b68e0f7afa4413 (diff)
Handle writing to root node
Diffstat (limited to 'src')
-rw-r--r--src/database.ts10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/database.ts b/src/database.ts
index 70aecf4..9ac31ea 100644
--- a/src/database.ts
+++ b/src/database.ts
@@ -53,9 +53,13 @@ export class Database implements DatabaseInterface {
}
async write(path: string, toWrite: any): Promise<void> {
- const pathParts = splitPath(path);
- const writeTo = this.resolve(pathParts, false, 1);
- writeTo[last(pathParts)] = toWrite;
+ if (path === "/") {
+ this.buff = toWrite;
+ } else {
+ const pathParts = splitPath(path);
+ const writeTo = this.resolve(pathParts, false, 1);
+ writeTo[last(pathParts)] = toWrite;
+ }
await this.serialize();
}