-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Questions and utils functions refactoring
- Loading branch information
Franck
committed
Jun 4, 2019
1 parent
aa6e3eb
commit 177c086
Showing
8 changed files
with
83 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const getProjectNameQuestion = require('./project-name') | ||
const getProjectDescriptionQuestion = require('./project-description') | ||
|
||
module.exports = { | ||
getProjectNameQuestion, | ||
getProjectDescriptionQuestion | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const get = require('lodash/get') | ||
|
||
const { getPackageJson } = require('../utils') | ||
|
||
module.exports = async () => { | ||
const packageJson = await getPackageJson() | ||
|
||
return { | ||
type: 'input', | ||
message: 'Enter your project description', | ||
name: 'projectDescription', | ||
default: get(packageJson, 'description', undefined) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const getProjectName = require('project-name') | ||
|
||
module.exports = () => ({ | ||
type: 'input', | ||
message: 'Enter your project name', | ||
name: 'projectName', | ||
default: getProjectName() || undefined | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const util = require('util') | ||
const readFile = util.promisify(require('fs').readFile) | ||
const writeFile = util.promisify(require('fs').writeFile) | ||
const loadJsonFile = require('load-json-file') | ||
|
||
/** | ||
* Create readme file from the given readmeContent | ||
* | ||
* @param {string} readmeContent | ||
*/ | ||
const createReadme = async readmeContent => | ||
await writeFile('README.md', readmeContent) | ||
|
||
/** | ||
* Get template content from the given templateName | ||
* | ||
* @param {string} templateName | ||
*/ | ||
const getTemplate = async templateName => | ||
await readFile(`./templates/${templateName}.md`, 'utf8') | ||
|
||
/** | ||
* Get package.json content | ||
*/ | ||
const getPackageJson = async () => { | ||
let packageJson = undefined | ||
|
||
try { | ||
packageJson = await loadJsonFile('package.json') | ||
} catch (err) { | ||
// eslint-disable-next-line no-empty | ||
} | ||
|
||
return packageJson | ||
} | ||
|
||
module.exports = { | ||
getPackageJson, | ||
getTemplate, | ||
createReadme | ||
} |