effects-as-data-generate
Advanced tools
Comparing version 2.2.0 to 2.2.2
@@ -44,2 +44,7 @@ const c = require('case'); | ||
function* writeFunction({ nameCamel, fileName, settings }) { | ||
const filePath = path.join(settings.functionsPath, fileName + '.js'); | ||
const $fnAlreadyExists = yield actions.fileExists(filePath); | ||
if (isFailure($fnAlreadyExists)) return $fnAlreadyExists; | ||
if ($fnAlreadyExists.payload) | ||
return failure(`${nameCamel}() already exists.`); | ||
const $functionTemplate = yield actions.readFile( | ||
@@ -55,10 +60,12 @@ path.join(__dirname, '../../templates/fn.js.txt'), | ||
); | ||
return yield actions.writeFile( | ||
path.join(settings.functionsPath, fileName + '.js'), | ||
functionText, | ||
{ encoding: 'utf8' } | ||
); | ||
return yield actions.writeFile(filePath, functionText, { encoding: 'utf8' }); | ||
} | ||
function* writeSpec({ nameCamel, namePascal, fileName, settings }) { | ||
const filePath = path.join(settings.functionsPath, fileName + '.spec.js'); | ||
const $specAlreadExists = yield actions.fileExists(filePath); | ||
if (isFailure($specAlreadExists)) return $specAlreadExists; | ||
if ($specAlreadExists.payload) | ||
return failure(`${nameCamel}() spec already exists.`); | ||
const $specTemplate = yield actions.readFile( | ||
@@ -74,7 +81,3 @@ path.join(__dirname, '../../templates/spec.js.txt'), | ||
)($specTemplate.payload); | ||
return yield actions.writeFile( | ||
path.join(settings.functionsPath, fileName + '.spec.js'), | ||
specText, | ||
{ encoding: 'utf8' } | ||
); | ||
return yield actions.writeFile(filePath, specText, { encoding: 'utf8' }); | ||
} | ||
@@ -91,3 +94,3 @@ | ||
}); | ||
const indexString = JSON.stringify(updatedFunctionsIndex); | ||
const indexString = JSON.stringify(updatedFunctionsIndex, true, 2); | ||
const $writeResult = yield actions.writeFile(indexPath, indexString, { | ||
@@ -94,0 +97,0 @@ encoding: 'utf8' |
@@ -1,7 +0,7 @@ | ||
const {run, buildFunctions} = require('effects-as-data'); | ||
const { run, buildFunctions } = require('effects-as-data'); | ||
const handlers = require('./handlers'); | ||
const functions = require('./functions'); | ||
const fxns = buildFunctions(handlers, functions); | ||
const fxns = buildFunctions(handlers, functions, { onFailure: () => {} }); | ||
module.exports = fxns; |
@@ -21,3 +21,3 @@ const program = require('commander'); | ||
function printSuccess(result) { | ||
console.error(chalk.green(result.payload.message)); | ||
console.log(chalk.green(result.payload.message)); | ||
} | ||
@@ -24,0 +24,0 @@ |
{ | ||
"name": "effects-as-data-generate", | ||
"version": "2.2.0", | ||
"version": "2.2.2", | ||
"description": "", | ||
@@ -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
11139
269