Skip to content

Commit 5e26855

Browse files
committed
Eliminated long lines
1 parent addba86 commit 5e26855

File tree

6 files changed

+56
-32
lines changed

6 files changed

+56
-32
lines changed

generate-ip/src/cli.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ const pkgName = 'generate-ip',
2525
// Load sys LANGUAGE
2626
let langCode = 'en'
2727
if (process.platform == 'win32') {
28-
try { langCode = execSync('(Get-Culture).TwoLetterISOLanguageName', { shell: 'powershell', encoding: 'utf-8' }).trim() }
29-
catch (err) { printIfNotQuiet(`Error loading system language: ${err}`) }
28+
try {
29+
langCode = execSync('(Get-Culture).TwoLetterISOLanguageName',
30+
{ shell: 'powershell', encoding: 'utf-8' }).trim()
31+
} catch (err) { printIfNotQuiet(`Error loading system language: ${err}`) }
3032
} else { // macOS/Linux
3133
const env = process.env
3234
langCode = (env.LANG || env.LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LC_NAME || 'en')?.split('.')[0]
@@ -48,7 +50,7 @@ const pkgName = 'generate-ip',
4850
flatMsgs[key] = msgs[key].message
4951
resolve(flatMsgs)
5052
} catch (err) { // if bad response
51-
msgFetchTries++ ; if (msgFetchTries == 3) return resolve({}) // try up to 3X (original/region-stripped/EN) only
53+
msgFetchTries++ ; if (msgFetchTries == 3) return resolve({}) // try original/region-stripped/EN only
5254
msgHref = langCode.includes('-') && msgFetchTries == 1 ? // if regional lang on 1st try...
5355
msgHref.replace(/([^_]*)_[^/]*(\/.*)/, '$1$2') // ...strip region before retrying
5456
: ( msgHostURL + 'en/messages.json' ) // else use default English messages
@@ -171,7 +173,8 @@ const pkgName = 'generate-ip',
171173
}
172174
includeSections.forEach(section => // print valid arg elems
173175
helpSections[section]?.forEach(line => printHelpMsg(line, /header|usage/.test(section) ? 1 : 29)))
174-
console.info(`\n${ msgs.info_moreHelp || 'For more help' }, ${ msgs.info_visit || 'visit' }: ${ bw + docURL + nc }`)
176+
console.info(
177+
`\n${ msgs.info_moreHelp || 'For more help' }, ${ msgs.info_visit || 'visit' }: ${ bw + docURL + nc }`)
175178

176179
function printHelpMsg(msg, indent) { // wrap msg + indent 2nd+ lines
177180
const terminalWidth = process.stdout.columns || 80,

generate-pw/src/cli.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ const pkgName = 'generate-pw',
2525
// Load sys LANGUAGE
2626
let langCode = 'en'
2727
if (process.platform == 'win32') {
28-
try { langCode = execSync('(Get-Culture).TwoLetterISOLanguageName', { shell: 'powershell', encoding: 'utf-8' }).trim() }
29-
catch (err) { printIfNotQuiet(`Error loading system language: ${err}`) }
28+
try {
29+
langCode = execSync('(Get-Culture).TwoLetterISOLanguageName',
30+
{ shell: 'powershell', encoding: 'utf-8' }).trim()
31+
} catch (err) { printIfNotQuiet(`Error loading system language: ${err}`) }
3032
} else { // macOS/Linux
3133
const env = process.env
3234
langCode = (env.LANG || env.LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LC_NAME || 'en')?.split('.')[0]
@@ -48,7 +50,7 @@ const pkgName = 'generate-pw',
4850
flatMsgs[key] = msgs[key].message
4951
resolve(flatMsgs)
5052
} catch (err) { // if bad response
51-
msgFetchTries++ ; if (msgFetchTries == 3) return resolve({}) // try up to 3X (original/region-stripped/EN) only
53+
msgFetchTries++ ; if (msgFetchTries == 3) return resolve({}) // try original/region-stripped/EN only
5254
msgHref = langCode.includes('-') && msgFetchTries == 1 ? // if regional lang on 1st try...
5355
msgHref.replace(/([^_]*)_[^/]*(\/.*)/, '$1$2') // ...strip region before retrying
5456
: ( msgHostURL + 'en/messages.json' ) // else use default English messages
@@ -195,7 +197,8 @@ const pkgName = 'generate-pw',
195197
}
196198
includeSections.forEach(section => // print valid arg elems
197199
helpSections[section]?.forEach(line => printHelpMsg(line, /header|usage/.test(section) ? 1 : 29)))
198-
console.info(`\n${ msgs.info_moreHelp || 'For more help' }, ${ msgs.info_visit || 'visit' }: ${ bw + docURL + nc }`)
200+
console.info(
201+
`\n${ msgs.info_moreHelp || 'For more help' }, ${ msgs.info_visit || 'visit' }: ${ bw + docURL + nc }`)
199202

200203
function printHelpMsg(msg, indent) { // wrap msg + indent 2nd+ lines
201204
const terminalWidth = process.stdout.columns || 80,

generate-pw/src/generate-pw.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ function generatePassword(options = {}) {
4141
return generatePasswords(qty, nonQtyOptions)
4242

4343
} else { // generate/return single password
44-
const fromGeneratePasswords = generatePassword.caller?.name == 'generatePasswords' // flag to avoid repetitive logs
44+
const fromGeneratePasswords = generatePassword.caller?.name == 'generatePasswords' // to avoid repetitive logs
4545

4646
// Init password's char set
47-
if (options.verbose && !fromGeneratePasswords) console.info('generatePassword() » Initializing character set...')
47+
if (options.verbose && !fromGeneratePasswords)
48+
console.info('generatePassword() » Initializing character set...')
4849
let pwCharset = options.charset?.toString() || ( // use passed [charset], or construct from options
4950
(options.numbers ? charsets.numbers : '')
5051
+ (options.symbols ? charsets.symbols : '')
@@ -56,13 +57,15 @@ function generatePassword(options = {}) {
5657

5758
// Exclude passed `exclude` chars
5859
if (options.exclude) {
59-
if (options.verbose && !fromGeneratePasswords) console.info('generatePassword() » Removing excluded characters...')
60+
if (options.verbose && !fromGeneratePasswords)
61+
console.info('generatePassword() » Removing excluded characters...')
6062
pwCharset = pwCharset.replace(new RegExp(`[${options.exclude}]`, 'g'), '')
6163
}
6264

6365
// Exclude similar chars if `excludeSimilarChars` is `true`
6466
if (options.excludeSimilarChars) {
65-
if (options.verbose && !fromGeneratePasswords) console.info('generatePassword() » Excluding similar characters...')
67+
if (options.verbose && !fromGeneratePasswords)
68+
console.info('generatePassword() » Excluding similar characters...')
6669
pwCharset = pwCharset.replace(/[o0Oil1|]/g, '')
6770
}
6871

@@ -77,8 +80,9 @@ function generatePassword(options = {}) {
7780
// Enforce strict mode if enabled
7881
if (options.strict) {
7982
if (options.verbose && !fromGeneratePasswords) console.info('generatePassword() » Enforcing strict mode...')
80-
const charTypes = ['number', 'symbol', 'lower', 'upper'],
81-
requiredCharTypes = charTypes.filter(charType => options[charType + 's'] || options[charType + 'case'])
83+
const charTypes = ['number', 'symbol', 'lower', 'upper']
84+
const requiredCharTypes = charTypes
85+
.filter(charType => options[`${charType}s`] || options[`${charType}case`])
8286
password = strictify(password, requiredCharTypes)
8387
}
8488

geolocate/src/cli.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ const pkgName = '@adamlui/geolocate',
2525
// Load sys LANGUAGE
2626
let langCode = 'en'
2727
if (process.platform == 'win32') {
28-
try { langCode = execSync('(Get-Culture).TwoLetterISOLanguageName', { shell: 'powershell', encoding: 'utf-8' }).trim() }
29-
catch (err) { printIfNotQuiet(`Error loading system language: ${err}`) }
28+
try {
29+
langCode = execSync('(Get-Culture).TwoLetterISOLanguageName',
30+
{ shell: 'powershell', encoding: 'utf-8' }).trim()
31+
} catch (err) { printIfNotQuiet(`Error loading system language: ${err}`) }
3032
} else { // macOS/Linux
3133
const env = process.env
3234
langCode = (env.LANG || env.LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LC_NAME || 'en')?.split('.')[0]
@@ -47,7 +49,7 @@ const pkgName = '@adamlui/geolocate',
4749
flatMsgs[key] = msgs[key].message
4850
resolve(flatMsgs)
4951
} catch (err) { // if bad response
50-
msgFetchTries++ ; if (msgFetchTries == 3) return resolve({}) // try up to 3X (original/region-stripped/EN) only
52+
msgFetchTries++ ; if (msgFetchTries == 3) return resolve({}) // try original/region-stripped/EN only
5153
msgHref = langCode.includes('-') && msgFetchTries == 1 ? // if regional lang on 1st try...
5254
msgHref.replace(/([^_]*)_[^/]*(\/.*)/, '$1$2') // ...strip region before retrying
5355
: ( msgHostURL + 'en/messages.json' ) // else use default English messages
@@ -167,7 +169,8 @@ const pkgName = '@adamlui/geolocate',
167169
}
168170
includeSections.forEach(section => // print valid arg elems
169171
helpSections[section]?.forEach(line => printHelpMsg(line, /header|usage/.test(section) ? 1 : 29)))
170-
console.info(`\n${ msgs.info_moreHelp || 'For more help' }, ${ msgs.info_visit || 'visit' }: ${ bw + docURL + nc }`)
172+
console.info(
173+
`\n${ msgs.info_moreHelp || 'For more help' }, ${ msgs.info_visit || 'visit' }: ${ bw + docURL + nc }`)
171174

172175
function printHelpMsg(msg, indent) { // wrap msg + indent 2nd+ lines
173176
const terminalWidth = process.stdout.columns || 80,

minify.js/node.js/src/cli.js

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ const pkgName = '@adamlui/minify.js',
2626
// Load sys LANGUAGE
2727
let langCode = 'en'
2828
if (process.platform == 'win32') {
29-
try { langCode = execSync('(Get-Culture).TwoLetterISOLanguageName', { shell: 'powershell', encoding: 'utf-8' }).trim() }
30-
catch (err) { printIfNotQuiet(`Error loading system language: ${err}`) }
29+
try {
30+
langCode = execSync('(Get-Culture).TwoLetterISOLanguageName',
31+
{ shell: 'powershell', encoding: 'utf-8' }).trim()
32+
} catch (err) { printIfNotQuiet(`Error loading system language: ${err}`) }
3133
} else { // macOS/Linux
3234
const env = process.env
3335
langCode = (env.LANG || env.LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LC_NAME || 'en')?.split('.')[0]
@@ -48,7 +50,7 @@ const pkgName = '@adamlui/minify.js',
4850
flatMsgs[key] = msgs[key].message
4951
resolve(flatMsgs)
5052
} catch (err) { // if bad response
51-
msgFetchTries++ ; if (msgFetchTries == 3) return resolve({}) // try up to 3X (original/region-stripped/EN) only
53+
msgFetchTries++ ; if (msgFetchTries == 3) return resolve({}) // try original/region-stripped/EN only
5254
msgHref = langCode.includes('-') && msgFetchTries == 1 ? // if regional lang on 1st try...
5355
msgHref.replace(/([^_]*)_[^/]*(\/.*)/, '$1$2') // ...strip region before retrying
5456
: ( msgHostURL + 'en/messages.json' ) // else use default English messages
@@ -147,8 +149,10 @@ const pkgName = '@adamlui/minify.js',
147149

148150
// Find all eligible JavaScript files or arg-passed file
149151
const unminnedJSfiles = inputPath.endsWith('.js') && !fs.statSync(inputPath).isDirectory() ? [inputPath]
150-
: minifyJS.findJS(inputPath, { recursive: !config.noRecursion, verbose: !config.quietMode,
151-
ignoreFiles: (config.ignoreFiles?.split(',') ?? []).map(file => file.trim()) })
152+
: minifyJS.findJS(inputPath, {
153+
recursive: !config.noRecursion, verbose: !config.quietMode,
154+
ignoreFiles: (config.ignoreFiles?.split(',') ?? []).map(file => file.trim())
155+
})
152156

153157
if (config.dryRun) { // -n or --dry-run passed
154158
if (unminnedJSfiles.length > 0) { // print files to be processed
@@ -172,10 +176,13 @@ const pkgName = '@adamlui/minify.js',
172176
printIfNotQuiet(`\n${bg + ( msgs.info_minComplete || 'Minification complete' )}!${nc}`)
173177
printIfNotQuiet(`${bw + minifyData.length} ${ msgs.info_file || 'file' }`
174178
+ `${ minifyData.length > 1 ? 's' : '' } ${ msgs.info_minified || 'minified' }.${nc}`)
175-
} else printIfNotQuiet(`\n${by + ( msgs.info_noFilesProcessed || 'No unminified JavaScript files processed' )}.${nc}`)
179+
} else printIfNotQuiet(
180+
`\n${by + ( msgs.info_noFilesProcessed || 'No unminified JavaScript files processed' )}.${nc}`)
176181
if (failedPaths.length > 0) {
177-
printIfNotQuiet(`\n${br + failedPaths.length} ${ msgs.info_file || 'file' }`
178-
+ `${ failedPaths.length > 1 ? 's' : '' } ${ msgs.info_failedToMinify || 'failed to minify' }:${nc}`)
182+
printIfNotQuiet(
183+
`\n${br + failedPaths.length} ${ msgs.info_file || 'file' }`
184+
+ `${ failedPaths.length > 1 ? 's' : '' } ${ msgs.info_failedToMinify || 'failed to minify' }:${nc}`
185+
)
179186
failedPaths.forEach(path => printIfNotQuiet(path))
180187
}
181188
if (minifyData?.length == 0) return
@@ -187,13 +194,14 @@ const pkgName = '@adamlui/minify.js',
187194
ncp.writeSync(minifyData[0].code)
188195

189196
} else { // write array data to files
190-
printIfNotQuiet(`\n${ msgs.info_writing || 'Writing to file' }${ minifyData?.length > 1 ? 's' : '' }...`)
197+
printIfNotQuiet(
198+
`\n${ msgs.info_writing || 'Writing to file' }${ minifyData?.length > 1 ? 's' : '' }...`)
191199
minifyData?.forEach(({ code, srcPath }) => {
192200
const outputDir = path.join(
193201
path.dirname(srcPath), // path of file to be minified
194202
( /so?u?rce?$/.test(path.dirname(srcPath)) ? '../' : '' ) // + '../' if in if in *(src|source)/
195203
+ ( outputArg.endsWith('.js') ? path.dirname(outputArg) // + path from file outputArg
196-
: outputArg || 'min' ) // or path from folder outputArg or min/ if no outputArg passed
204+
: outputArg || 'min' ) // or path from folder outputArg or min/ if no outputArg passed
197205
)
198206
const outputFilename = (
199207
outputArg.endsWith('.js') && inputArg.endsWith('.js')
@@ -270,7 +278,8 @@ const pkgName = '@adamlui/minify.js',
270278
}
271279
includeSections.forEach(section => // print valid arg elems
272280
helpSections[section]?.forEach(line => printHelpMsg(line, /header|usage/.test(section) ? 1 : 37)))
273-
console.info(`\n${ msgs.info_moreHelp || 'For more help' }, ${ msgs.info_visit || 'visit' }: ${ bw + docURL + nc }`)
281+
console.info(
282+
`\n${ msgs.info_moreHelp || 'For more help' }, ${ msgs.info_visit || 'visit' }: ${ bw + docURL + nc }`)
274283

275284
function printHelpMsg(msg, indent) { // wrap msg + indent 2nd+ lines
276285
const terminalWidth = process.stdout.columns || 80,

scss-to-css/node.js/src/cli.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@
104104

105105
// Find all eligible JavaScript files or arg-passed file
106106
const scssFiles = inputPath.endsWith('.scss') && !fs.statSync(inputPath).isDirectory() ? [inputPath]
107-
: scssToCSS.findSCSS(inputPath, { recursive: !config.noRecursion, verbose: !config.quietMode,
108-
ignoreFiles: (config.ignoreFiles?.split(',') ?? []).map(file => file.trim()) })
107+
: scssToCSS.findSCSS(inputPath, {
108+
recursive: !config.noRecursion, verbose: !config.quietMode,
109+
ignoreFiles: (config.ignoreFiles?.split(',') ?? []).map(file => file.trim())
110+
})
109111

110112
if (config.dryRun) { // -n or --dry-run passed
111113
if (scssFiles.length > 0) { // print files to be processed
@@ -156,7 +158,7 @@
156158
/(?:src|s[ac]ss)$/.test(path.dirname(srcPath)) ? (
157159
'../' + ( outputArg || 'css' ) // + ../outputArg|css/ if in *(src|sass|scss)/
158160
) : outputArg.endsWith('.css') ? path.dirname(outputArg) // or path from file output arg
159-
: outputArg || 'css' // or path from folder outputArg or css/ if no outputArg passed
161+
: outputArg || 'css' // or path from folder outputArg or css/ if no outputArg passed
160162
)
161163
const outputFilename = (
162164
outputArg.endsWith('.css') && inputArg.endsWith('.scss')

0 commit comments

Comments
 (0)