configuration
Advanced tools
Comparing version 1.3.3 to 1.4.0
@@ -0,1 +1,2 @@ | ||
import { WriteOptions } from 'atomically/dist/types'; | ||
import { FSWatcher } from 'chokidar'; | ||
@@ -8,2 +9,4 @@ import { ProviderFileOptions } from '../types'; | ||
watcher?: FSWatcher; | ||
writeOptions?: WriteOptions; | ||
writeSyncOptions?: WriteOptions; | ||
constructor(options: Partial<Options>); | ||
@@ -10,0 +13,0 @@ dispose(): void; |
@@ -11,2 +11,4 @@ "use strict"; | ||
this.watching = !!options.watch; | ||
this.writeOptions = options.writeOptions; | ||
this.writeSyncOptions = options.writeSyncOptions; | ||
this.swap(options.path, true); | ||
@@ -13,0 +15,0 @@ } |
@@ -46,3 +46,3 @@ "use strict"; | ||
await super.write(data, true); | ||
file_1.default.write(this.path, this.dataRaw); | ||
file_1.default.write(this.path, this.dataRaw, this.writeOptions); | ||
} | ||
@@ -55,3 +55,3 @@ writeSync(data, force = false) { | ||
super.writeSync(data, true); | ||
file_1.default.writeSync(this.path, this.dataRaw); | ||
file_1.default.writeSync(this.path, this.dataRaw, this.writeSyncOptions); | ||
} | ||
@@ -58,0 +58,0 @@ } |
@@ -0,1 +1,2 @@ | ||
import { WriteOptions } from 'atomically/dist/types'; | ||
import { ValidateFunction } from 'ajv'; | ||
@@ -56,2 +57,4 @@ import { JSONSchema7 } from 'json-schema'; | ||
watch?: boolean; | ||
writeOptions?: WriteOptions; | ||
writeSyncOptions?: WriteOptions; | ||
}; | ||
@@ -58,0 +61,0 @@ declare type ProviderJSONOptions = ProviderFileOptions; |
@@ -1,11 +0,10 @@ | ||
/// <reference types="node" /> | ||
import { readFile, readFileSync } from 'atomically'; | ||
import { FSWatcher } from 'chokidar'; | ||
import * as fs from 'graceful-fs'; | ||
declare const File: { | ||
read: typeof fs.readFile.__promisify__; | ||
readSync: typeof fs.readFileSync; | ||
write(filePath: string, content: string): Promise<void>; | ||
writeSync(filePath: string, content: string): void; | ||
read: typeof readFile; | ||
readSync: typeof readFileSync; | ||
write: (filePath: string, data: import("atomically/dist/types").Data, options?: string | import("atomically/dist/types").WriteOptions | import("atomically/dist/types").Callback | undefined, callback?: import("atomically/dist/types").Callback | undefined) => Promise<void>; | ||
writeSync: (filePath: string, data: import("atomically/dist/types").Data, options?: string | import("atomically/dist/types").WriteOptions | undefined) => void; | ||
watch(filePath: string, callback: Function): FSWatcher; | ||
}; | ||
export default File; |
"use strict"; | ||
/* IMPORT */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const fs = require("graceful-fs"); | ||
const path = require("path"); | ||
const util = require("util"); | ||
const folder_1 = require("./folder"); | ||
const atomically_1 = require("atomically"); | ||
/* FILE */ | ||
const File = { | ||
read: util.promisify(fs.readFile), | ||
readSync: fs.readFileSync, | ||
write(filePath, content) { | ||
const writeFileAtomic = util.promisify(require('write-file-atomic')); // Lazy import for performance | ||
const folderPath = path.dirname(filePath); | ||
return folder_1.default.ensure(folderPath).then(() => writeFileAtomic(filePath, content)); | ||
}, | ||
writeSync(filePath, content) { | ||
const writeFileAtomic = require('write-file-atomic'); // Lazy import for performance | ||
const folderPath = path.dirname(filePath); | ||
folder_1.default.ensureSync(folderPath); | ||
return writeFileAtomic.sync(filePath, content); | ||
}, | ||
read: atomically_1.readFile, | ||
readSync: atomically_1.readFileSync, | ||
write: atomically_1.writeFile, | ||
writeSync: atomically_1.writeFileSync, | ||
watch(filePath, callback) { | ||
@@ -24,0 +12,0 @@ const watcher = require('chokidar-watcher'); // Lazy import for performance |
{ | ||
"name": "configuration", | ||
"description": "Performant and feature rich library for managing configurations/settings.", | ||
"version": "1.3.3", | ||
"version": "1.4.0", | ||
"main": "dist/index.js", | ||
@@ -51,4 +51,4 @@ "types": "dist/index.d.ts", | ||
"ajv-filter": "^1.1.1", | ||
"atomically": "^1.3.0", | ||
"chokidar-watcher": "^1.4.1", | ||
"graceful-fs": "^4.2.4", | ||
"is-primitive": "^3.0.1", | ||
@@ -59,4 +59,3 @@ "json5": "^2.1.3", | ||
"plain-object-is-equal": "^1.0.0", | ||
"plain-object-merge": "^1.0.1", | ||
"write-file-atomic": "^3.0.3" | ||
"plain-object-merge": "^1.0.1" | ||
}, | ||
@@ -67,7 +66,5 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"@types/graceful-fs": "^4.1.3", | ||
"@types/json-schema": "^7.0.4", | ||
"@types/json5": "0.0.30", | ||
"@types/node": "^14.0.5", | ||
"@types/write-file-atomic": "^3.0.0", | ||
"ava": "^2.4.0", | ||
@@ -74,0 +71,0 @@ "ava-spec": "^1.1.1", |
/* IMPORT */ | ||
import {WriteOptions} from 'atomically/dist/types'; | ||
import {FSWatcher} from 'chokidar'; | ||
@@ -16,2 +17,4 @@ import {ProviderFileOptions} from '../types'; | ||
watcher?: FSWatcher; | ||
writeOptions?: WriteOptions; | ||
writeSyncOptions?: WriteOptions; | ||
@@ -23,2 +26,4 @@ constructor ( options: Partial<Options> ) { | ||
this.watching = !!options.watch; | ||
this.writeOptions = options.writeOptions; | ||
this.writeSyncOptions = options.writeSyncOptions; | ||
@@ -25,0 +30,0 @@ this.swap ( options.path, true ); |
@@ -66,3 +66,3 @@ | ||
File.write ( this.path, this.dataRaw ); | ||
File.write ( this.path, this.dataRaw, this.writeOptions ); | ||
@@ -79,3 +79,3 @@ } | ||
File.writeSync ( this.path, this.dataRaw ); | ||
File.writeSync ( this.path, this.dataRaw, this.writeSyncOptions ); | ||
@@ -82,0 +82,0 @@ } |
/* IMPORT */ | ||
import {WriteOptions} from 'atomically/dist/types'; | ||
import {ValidateFunction} from 'ajv'; | ||
@@ -75,3 +76,5 @@ import {JSONSchema7} from 'json-schema'; | ||
path: string, | ||
watch?: boolean | ||
watch?: boolean, | ||
writeOptions?: WriteOptions, | ||
writeSyncOptions?: WriteOptions | ||
}; | ||
@@ -78,0 +81,0 @@ |
/* IMPORT */ | ||
import {readFile, readFileSync, writeFile, writeFileSync} from 'atomically'; | ||
import {FSWatcher} from 'chokidar'; | ||
import * as fs from 'graceful-fs'; | ||
import * as path from 'path'; | ||
import * as util from 'util'; | ||
import Folder from './folder'; | ||
@@ -13,15 +10,6 @@ /* FILE */ | ||
const File = { | ||
read: util.promisify ( fs.readFile ), | ||
readSync: fs.readFileSync, | ||
write ( filePath: string, content: string ): Promise<void> { | ||
const writeFileAtomic = util.promisify ( require ( 'write-file-atomic' ) ); // Lazy import for performance | ||
const folderPath = path.dirname ( filePath ); | ||
return Folder.ensure ( folderPath ).then ( () => writeFileAtomic ( filePath, content ) ); | ||
}, | ||
writeSync ( filePath: string, content: string ): void { | ||
const writeFileAtomic = require ( 'write-file-atomic' ); // Lazy import for performance | ||
const folderPath = path.dirname ( filePath ); | ||
Folder.ensureSync ( folderPath ); | ||
return writeFileAtomic.sync ( filePath, content ); | ||
}, | ||
read: readFile, | ||
readSync: readFileSync, | ||
write: writeFile, | ||
writeSync: writeFileSync, | ||
watch ( filePath: string, callback: Function ): FSWatcher { | ||
@@ -28,0 +16,0 @@ const watcher = require ( 'chokidar-watcher' ); // Lazy import for performance |
11
13
104819
53
2752
+ Addedatomically@^1.3.0
+ Addedatomically@1.7.0(transitive)
- Removedgraceful-fs@^4.2.4
- Removedwrite-file-atomic@^3.0.3
- Removedgraceful-fs@4.2.11(transitive)
- Removedimurmurhash@0.1.4(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedtypedarray-to-buffer@3.1.5(transitive)
- Removedwrite-file-atomic@3.0.3(transitive)