handle type mismatch
This commit is contained in:
@@ -275,10 +275,10 @@ async function getDirectoryServerCertificate() {
|
||||
// write if contents mismatch
|
||||
function writeFileSync(filePath, data) {
|
||||
assert.strictEqual(typeof filePath, 'string');
|
||||
assert(Buffer.isBuffer(data) || typeof data === 'string'); // domain and location stores certs as json but not acme
|
||||
assert.strictEqual(typeof data, 'string');
|
||||
|
||||
const curData = safe.fs.readFileSync(filePath);
|
||||
if (curData && curData.equals(Buffer.from(data))) return;
|
||||
const curData = safe.fs.readFileSync(filePath, { encoding: 'utf8' });
|
||||
if (curData === data) return;
|
||||
if (!safe.fs.writeFileSync(filePath, data)) throw new BoxError(BoxError.FS_ERROR, safe.error.message);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user