-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(init): creates the contributor file if not found (#158)
* feat(init): creates the contributor file if not found If not found, the specified contributor file (defaulting to `README.md`) will be created prior to injections in it. re all-contributors/app#105 * refactor(init): renamed a module and its export Renamed `check-file` to `file-exist` and its exported function to `ensureFileExists` * test(init): added contributors file test Added two test cases for the contributors file existence check
- Loading branch information
1 parent
9aa7948
commit febecff
Showing
3 changed files
with
35 additions
and
0 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 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,11 @@ | ||
const fs = require('fs') | ||
|
||
module.exports = function ensureFileExists(file) { | ||
return new Promise((resolve, reject) => { | ||
if (fs.existsSync(file)) return resolve(file) | ||
fs.writeFile(file, '', err => { | ||
if (err) reject(err) | ||
resolve(file) | ||
}) | ||
}) | ||
} |
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