-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* build, jest setupTests * deps, convenience log * testing, expand content-types
- Loading branch information
Showing
13 changed files
with
1,146 additions
and
974 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 |
---|---|---|
|
@@ -10,6 +10,7 @@ coverage | |
*.lcov | ||
|
||
# logs | ||
dependency-update-log.txt | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
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 { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } = require('fs'); | ||
const crypto = require('crypto'); | ||
const { extname, join, resolve } = require('path'); | ||
|
||
global.__basedir = __dirname; | ||
|
||
/** | ||
* Generate a fixture from string literals. | ||
* | ||
* @param {string} contents | ||
* @param {object} options | ||
* @param {string} options.dir | ||
* @param {string} options.ext | ||
* @param {string} options.encoding | ||
* @param {string} options.filename | ||
* @param {boolean} options.resetDir | ||
* @returns {{path: string, file: string, contents: *, dir: string}} | ||
*/ | ||
const generateFixture = ( | ||
contents, | ||
{ dir = resolve(__dirname, '.fixtures'), ext = 'txt', encoding = 'utf8', filename, resetDir = true } = {} | ||
) => { | ||
const updatedFileName = filename || crypto.createHash('md5').update(contents).digest('hex'); | ||
const file = extname(updatedFileName) ? updatedFileName : `${updatedFileName}.${ext}`; | ||
const path = join(dir, file); | ||
|
||
if (resetDir && existsSync(dir)) { | ||
rmSync(dir, { recursive: true }); | ||
} | ||
|
||
if (!existsSync(dir)) { | ||
mkdirSync(dir, { recursive: true }); | ||
} | ||
|
||
writeFileSync(path, contents, { encoding }); | ||
const updatedContents = readFileSync(path, { encoding }); | ||
|
||
return { dir, file, path, contents: updatedContents }; | ||
}; | ||
|
||
global.generateFixture = generateFixture; |
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,33 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# | ||
# main() | ||
# | ||
{ | ||
BLUE="\e[34m" | ||
GREEN="\e[32m" | ||
RED="\e[31m" | ||
YELLOW="\e[33m" | ||
NOCOLOR="\e[39m" | ||
|
||
printf "${YELLOW}Reset existing build dependencies...${NOCOLOR}" | ||
rm -rf -- ./node_modules | ||
yarn install | ||
|
||
printf $BLUE | ||
echo "Confirm and update build dependencies..." | ||
|
||
DEPS_UPDATE=$(ncu "$@"); | ||
echo $DEPS_UPDATE | ||
|
||
DEPS_LOG=$(ncu); | ||
echo $DEPS_LOG | ||
|
||
printf $NOCOLOR | ||
printf "${YELLOW}Generate dependency log...${NOCOLOR}" | ||
echo "Curiosity dependency update log" > ./dependency-update-log.txt | ||
echo "$DEPS_UPDATE" >> ./dependency-update-log.txt | ||
echo "$DEPS_LOG" >> ./dependency-update-log.txt | ||
printf "${GREEN}COMPLETED${NOCOLOR}\n" | ||
printf "${YELLOW}Log generated at ./dependency-update-log.txt${NOCOLOR}\n" | ||
} |
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
Oops, something went wrong.