couch-init2
Advanced tools
Comparing version 4.2.1 to 5.0.0
@@ -45,27 +45,13 @@ const { readFile, writeFile } = require('fs').promises | ||
const designDocPath = `${designDocFolder}/${designDocName}.js` | ||
try { | ||
let jsDesignDoc = require(designDocPath) | ||
// Allow to pass just the view object | ||
if (!jsDesignDoc._id) { | ||
jsDesignDoc = { | ||
_id: `_design/${designDocName}`, | ||
language: 'javascript', | ||
views: jsDesignDoc, | ||
} | ||
let jsDesignDoc = require(designDocPath) | ||
// Allow to pass just the view object | ||
if (!jsDesignDoc._id) { | ||
jsDesignDoc = { | ||
_id: `_design/${designDocName}`, | ||
language: 'javascript', | ||
views: jsDesignDoc, | ||
} | ||
stringifyJsDesignDoc(jsDesignDoc.views) | ||
return JSON.stringify(jsDesignDoc) | ||
} catch (err) { | ||
if (err.code !== 'MODULE_NOT_FOUND') throw err | ||
// Initialize the design doc if none is found | ||
// Return a stringify version to keep consistency | ||
// with what would the normal readFile | ||
const emptyDesignDoc = `module.exports = {}` | ||
// Initializing the missing design doc file | ||
await writeFile(designDocPath, emptyDesignDoc) | ||
return {} | ||
} | ||
stringifyJsDesignDoc(jsDesignDoc.views) | ||
return JSON.stringify(jsDesignDoc) | ||
} | ||
@@ -93,17 +79,3 @@ | ||
const designDocPath = `${designDocFolder}/${designDocName}.json` | ||
try { | ||
return await readFile(designDocPath, { encoding: 'utf-8' }) | ||
} catch (err) { | ||
if (err.code !== 'ENOENT') throw err | ||
// Initialize the design doc if none is found | ||
// Return a stringify version to keep consistency | ||
// with what would the normal readFile | ||
const emptyDesignDoc = JSON.stringify(emtpyDesignDoc(designDocName), null, 4) | ||
// Initializing the missing design doc file | ||
await writeFile(designDocPath, emptyDesignDoc) | ||
return {} | ||
} | ||
return readFile(designDocPath, { encoding: 'utf-8' }) | ||
} | ||
@@ -110,0 +82,0 @@ |
{ | ||
"name": "couch-init2", | ||
"version": "4.2.1", | ||
"version": "5.0.0", | ||
"description": "Opiniated CouchDB databases initializer", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14199
283