Skip to content

Commit

Permalink
fix: markdown linting
Browse files Browse the repository at this point in the history
Signed-off-by: Ourchitecture <[email protected]>
  • Loading branch information
ourchitectureio committed Sep 20, 2023
1 parent 52f9b58 commit 41b139f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .markdownlint-cli2.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
globs:
- '**/*.md'
ignores:
- '#node_modules'
- '**/node_modules'

config:
list-marker-space:
MD030:
ul_multi: 3
ul_single: 3
ul-indent:
MD007:
indent: 4
18 changes: 17 additions & 1 deletion src/libraries/node/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ const get = (key) => {

const getAsBoolean = (key) => {
if (hasKey(key) && process.env[key]) {
return JSON.parse(process.env[key])
return JSON.parse(process.env[key]) ? true : false
}

return false
}

Expand All @@ -28,11 +29,26 @@ const isContinuousIntegrationMode = () => {
return getAsBoolean('CI') === true
}

const isDebugMode = () => {
return getAsBoolean('DEBUG') === true
}

const isProductionMode = () => {
return get('NODE_ENV') === 'production'
}

const isNonProductionMode = () => {
return !isProductionMode()
}

module.exports = {
assertRequired,
get,
getAsBoolean,
getRequired,
hasKey,
isContinuousIntegrationMode,
isDebugMode,
isNonProductionMode,
isProductionMode,
}
5 changes: 2 additions & 3 deletions src/libraries/node/log.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const winston = require('winston')
const path = require('path')

const env = require('./env')
const host = require('./host')
Expand Down Expand Up @@ -54,7 +53,7 @@ const registerLoggerSingleton = (scriptFilePath) => {
}

logger = winston.createLogger({
level: process.env['DEBUG'] ? 'debug' : 'info',
level: env.isDebugMode() ? 'debug' : 'info',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
Expand All @@ -73,7 +72,7 @@ const registerLoggerSingleton = (scriptFilePath) => {
],
})

if (env.get('NODE_ENV') !== 'production') {
if (env.isNonProductionMode()) {
logger.add(
new winston.transports.Console({
format: winston.format.simple(),
Expand Down
6 changes: 4 additions & 2 deletions src/tasks/node/check/formatting.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const cmd = require('../../../libraries/node/cmd')
const env = require('../../../libraries/node/env')
const host = require('../../../libraries/node/host')
const log = require('../../../libraries/node/log')

Expand Down Expand Up @@ -51,6 +52,9 @@ const checkFormattingWithPrettier = async (scriptFilePath) => {
const commandArgv = [
'prettier',
'--check',
...(env.isDebugMode()
? ['--log-level', 'debug']
: ['--log-level', 'log']),
'--config',
host.getRelativeToRootPath('./.prettierrc.yaml'),
'--ignore-path',
Expand All @@ -66,8 +70,6 @@ const checkFormattingWithPrettier = async (scriptFilePath) => {
const checkFormattingWithMarkdownlint = async (scriptFilePath) => {
const commandArgv = [
'markdownlint-cli2',
'**/*.md',
'#node_modules',
'--config',
host.getRelativeToRootPath('./.markdownlint-cli2.yaml'),
]
Expand Down
5 changes: 4 additions & 1 deletion src/tasks/node/check/spelling.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const cmd = require('../../../libraries/node/cmd')
const env = require('../../../libraries/node/env')
const host = require('../../../libraries/node/host')
const log = require('../../../libraries/node/log')

Expand All @@ -17,7 +18,9 @@ const main = async (scriptFilePath) => {
'cspell',
host.getRelativeToRootPath('./'),
'--gitignore',
'--no-progress',
...(env.isDebugMode()
? ['--show-context', '--show-suggestions']
: ['--no-progress']),
'--config',
host.getRelativeToRootPath('./cspell.config.yaml'),
'--locale',
Expand Down

0 comments on commit 41b139f

Please sign in to comment.