Skip to content

Commit

Permalink
some small fixes, upgraded packages
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotberry committed Apr 24, 2024
1 parent b291428 commit bd7e9cf
Show file tree
Hide file tree
Showing 5 changed files with 202 additions and 222 deletions.
22 changes: 8 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const logIgnored = (arrayOfFilePaths, lengthBefore, opts, files) => {
)
}
const filesFoundInfo = (files, inputStr) => {
let numberFilesFoundInGlob = files.length
const numberFilesFoundInGlob = files.length
if (numberFilesFoundInGlob === 1) {
!global.silent && console.log(chalk.green(`found a file: ${files[0]}.`))
} else {
Expand All @@ -42,20 +42,14 @@ const filesFoundInfo = (files, inputStr) => {
}
}
const run = async (globPattern, userOpts) => {
var opts
if (userOpts) {
opts = Object.assign({}, config, userOpts)
} else {
opts = config
}
const opts = userOpts ? Object.assign({}, config, userOpts) : config;
global.verbose = opts.verbose
global.silent = opts.silent

global.verbose && console.log(`DEBUG ON`)
global.verbose &&
console.log(`globPattern: ${globPattern}, userOpts: ${userOpts}`)
let inputStr = await validateAndFormatInput(globPattern)
console.log(`inputStr: ${JSON.stringify(inputStr)}`)
const inputStr = await validateAndFormatInput(globPattern)
let files
if (inputStr.type === 'fileArray') {
files = inputStr.files
Expand All @@ -79,8 +73,8 @@ const run = async (globPattern, userOpts) => {
//get pending new/old filepaths given our current options loadout
let arrayOfFilePaths = []
let fileNumber = 1
for await (let file of files) {
let filePathInfo = await getFilePathInfo(
for await (const file of files) {
const filePathInfo = await getFilePathInfo(
file,
opts.fixTildes,
opts.numbered ? fileNumber++ : null
Expand All @@ -92,17 +86,17 @@ const run = async (globPattern, userOpts) => {
//bugfix
arrayOfFilePaths = arrayOfFilePaths.filter((f) => f !== null)

let lengthBefore = arrayOfFilePaths.length
const lengthBefore = arrayOfFilePaths.length
arrayOfFilePaths = await ignore(arrayOfFilePaths)
logIgnored(arrayOfFilePaths, lengthBefore, opts, files)

if (opts.dryrun) {
for await (let fileShit of arrayOfFilePaths) {
for await (const fileShit of arrayOfFilePaths) {
await baseLog(fileShit)
}
// console.log(resp.join('\n'))
} else {
for await (let file of arrayOfFilePaths) {
for await (const file of arrayOfFilePaths) {
await processOneFile(file, opts.rename)
await baseLog(file)
}
Expand Down
7 changes: 2 additions & 5 deletions lib/closest-parent-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,17 @@ async function findClosestParentDir(path1, path2) {
const relativePath2 = path.relative(commonPath, absolutePath2);

// Return the result as an object
let obj = {
const obj = {
name: commonDirName,
path: commonPath,
relativePaths: {
a: relativePath1,
b: relativePath2,
},
};
let str = `.../${obj.name}/${obj.relativePaths.a} -> .../${obj.name}/${obj.relativePaths.b}`;
return str;
return `.../${obj.name}/${obj.relativePaths.a} -> .../${obj.name}/${obj.relativePaths.b}`;
}
const baseLog = async (fpath) => {

console.log(`${fpath.oldParsed.base} -> ${fpath.newParsed.base}`)
}

export {findClosestParentDir, baseLog};
4 changes: 2 additions & 2 deletions lib/ignore.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let ignoreFn

const getIgnores = () => {
let ret = null
let ignores = config.ignores
const ignores = config.ignores
if (Array.isArray(ignores)) {
if (ignores.length > 0) {
ret = ignores
Expand All @@ -16,7 +16,7 @@ const getIgnores = () => {
}

const init = () => {
let conf = getIgnores()
const conf = getIgnores()
global.debug && console.log(`conf: ${conf}`)
if (conf !== null) {
let arrayOfFns = []
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
"license": "The Unlicense",
"dependencies": {
"chalk": "^5.3.0",
"change-case": "^5.4.3",
"change-case": "^5.4.4",
"fdir": "^6.1.1",
"picomatch": "^4.0.1",
"picomatch": "^4.0.2",
"rc": "^1.2.8",
"text-case": "^1.0.9",
"yargs": "^17.7.2"
Expand Down Expand Up @@ -75,11 +75,11 @@
},
"devDependencies": {
"chai": "^5.1.0",
"eslint": "^8.57.0",
"eslint": "^9.1.1",
"eslint-config-prettier": "^9.1.0",
"mocha": "^10.3.0",
"mocha": "^10.4.0",
"prettier": "^3.2.5",
"release-it": "^17.1.1"
"release-it": "^17.2.0"
},
"publishConfig": {
"executableFiles": [
Expand Down
Loading

0 comments on commit bd7e9cf

Please sign in to comment.