Skip to content

Commit

Permalink
refactor: Rename data functions
Browse files Browse the repository at this point in the history
  • Loading branch information
fabschurt committed Jun 14, 2023
1 parent e6b19c3 commit 3e84f85
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function normalizeEnvVarName(str) {
)
}

export async function parseFromJsonFile(
export async function parseDataFromJsonFile(
withSrcDir,
ifPathExists,
readFile,
Expand All @@ -26,7 +26,7 @@ export async function parseFromJsonFile(
})
}

export function parseFromEnv(envObject) {
export function parseDataFromEnv(envObject) {
return (
Object.fromEntries(
Object.entries(envObject)
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
rmDir,
} from '#src/utils/fs'
import { renderIndex, copyAssetDir } from '#src/build'
import { parseFromJsonFile, parseFromEnv } from '#src/data'
import { parseDataFromJsonFile, parseDataFromEnv } from '#src/data'
import { parseTranslations } from '#src/i18n'
import { parseJson } from '#src/utils/json'
import renderTemplate from '#src/renderTemplate/pug'
Expand Down
10 changes: 5 additions & 5 deletions tests/data.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { join } from 'node:path'
import { withTempDir } from '#tests/helpers'
import { withDir, ifPathExists, readFile } from '#src/utils/fs'
import { parseJson } from '#src/utils/json'
import { parseFromJsonFile, parseFromEnv } from '#src/data'
import { parseDataFromJsonFile, parseDataFromEnv } from '#src/data'

describe('#src/data', () => {
describe('parseFromJsonFile()', () => {
describe('parseDataFromJsonFile()', () => {
it('parses data from a pre-defined JSON file', async () => {
await withTempDir(async (prefixWithTempDir) => {
const dirPath = prefixWithTempDir('src')
Expand All @@ -18,7 +18,7 @@ describe('#src/data', () => {
await writeFile(jsonFilePath, '{"stuff": ["thing", "trinket", "gizmo"]}')

assert.deepStrictEqual(
await parseFromJsonFile(
await parseDataFromJsonFile(
withDir(dirPath),
ifPathExists,
readFile,
Expand All @@ -36,10 +36,10 @@ describe('#src/data', () => {
})
})

describe('parseFromEnv()', () => {
describe('parseDataFromEnv()', () => {
it('extracts data from the environment (thanks to a special prefix)', () => {
assert.deepStrictEqual(
parseFromEnv({
parseDataFromEnv({
EDITOR: 'vim',
LANG: 'en_US.UTF-8',
_MG_SECRET_PHONE_NUMBER: '+33777777777',
Expand Down

0 comments on commit 3e84f85

Please sign in to comment.