Comparing version 3.2.1 to 3.2.2
@@ -7,6 +7,10 @@ var _ = require('lodash'); | ||
var fsExtra = require('fs-extra'); | ||
var fs = require('fs'); | ||
var copy = Promise.promisify(fsExtra.copy); | ||
var mkdirs = Promise.promisify(fsExtra.mkdirs); | ||
var stat = Promise.promisify(fs.stat); | ||
var readFile = Promise.promisify(fs.readFile); | ||
var outputFile = Promise.promisify(fsExtra.outputFile); | ||
var hash = Promise.promisify(bcrypt.hash); | ||
var yaml = require('js-yaml'); | ||
@@ -64,2 +68,16 @@ function copyShieldFiles(basePath, configPath) { | ||
function createRoles(configPath, roles) { | ||
var rolesYml = path.join(configPath, 'shield', 'roles.yml'); | ||
return stat(rolesYml).then(function (arg) { | ||
return readFile(rolesYml, 'utf8').then(function (data) { | ||
var rolesConfig = yaml.safeLoad(data); | ||
_.assign(rolesConfig, roles); | ||
return outputFile(rolesYml, yaml.safeDump(rolesConfig)); | ||
}); | ||
}) | ||
.catch(function () { | ||
return Promise.resolve(); | ||
}); | ||
} | ||
module.exports = function writeShieldConfig(options) { | ||
@@ -71,2 +89,9 @@ return function (configPath) { | ||
.then(createUsersAndRoles(configPath, options.shield.users)) | ||
.then(function (result) { | ||
if (options.shield.roles) { | ||
return createRoles(configPath, options.shield.roles); | ||
} else { | ||
return result; | ||
} | ||
}) | ||
.thenReturn(configPath); | ||
@@ -73,0 +98,0 @@ } |
{ | ||
"name": "libesvm", | ||
"version": "3.2.1", | ||
"version": "3.2.2", | ||
"description": "libesvm is a library for managning an Elasticsearch process for development and testing.", | ||
@@ -30,2 +30,3 @@ "main": "index.js", | ||
"glob": "^6.0.1", | ||
"js-yaml": "^3.5.2", | ||
"lodash": "~2.4.1", | ||
@@ -32,0 +33,0 @@ "mkdirp": "~0.5.0", |
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
60899
1686
17
16
+ Addedjs-yaml@^3.5.2
+ Addedargparse@1.0.10(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedjs-yaml@3.14.1(transitive)
+ Addedsprintf-js@1.0.3(transitive)