Skip to content

Commit 77c3171

Browse files
ygj6ygj6
authored and
ygj6
committed
feat: add processed files statistic and output
1 parent eca4d16 commit 77c3171

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,5 @@ dist
106106
.DS_Store
107107

108108
.idea
109+
110+
package-lock.json

bin/vue-codemod.ts

+14-6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Module from 'module'
66

77
import * as yargs from 'yargs'
88
import * as globby from 'globby'
9+
import * as util from 'util'
910

1011
import createDebug from 'debug'
1112
import { question } from 'readline-sync'
@@ -21,6 +22,7 @@ import type { TransformationModule } from '../src/runTransformation'
2122

2223
const debug = createDebug('vue-codemod')
2324
const log = console.log.bind(console)
25+
let processFilePath: string[] = []
2426

2527
const {
2628
_: files,
@@ -61,9 +63,10 @@ const {
6163
// TODO: port the `Runner` interface of jscodeshift
6264
async function main() {
6365
// Remind user to back up files
64-
const answer = question('Warning!!\n ' +
65-
'This tool may overwrite files.\n' +
66-
'Enter yes to continue:'
66+
const answer = question(
67+
'Warning!!\n ' +
68+
'This tool may overwrite files.\n' +
69+
'Enter yes to continue:'
6770
)
6871
if (answer.trim() !== 'yes') {
6972
return
@@ -94,6 +97,10 @@ async function main() {
9497
}
9598
packageTransform()
9699
}
100+
const processFilePathList = processFilePath.join('\n')
101+
console.log(`--------------------------------------------------`)
102+
console.log(`Processed file:\n${processFilePathList}`)
103+
console.log(`Processed ${processFilePath.length} files`)
97104
}
98105
/**
99106
* process files by Transformation
@@ -106,9 +113,7 @@ function processTransformation(
106113
transformationName: string,
107114
transformationModule: TransformationModule
108115
) {
109-
log(
110-
`Processing ${resolvedPaths.length} files… use ${transformationName} transformation`
111-
)
116+
log(`Processing use ${transformationName} transformation`)
112117

113118
const extensions = ['.js', '.ts', '.vue', '.jsx', '.tsx']
114119
for (const p of resolvedPaths) {
@@ -129,6 +134,9 @@ function processTransformation(
129134
params as object
130135
)
131136
fs.writeFileSync(p, result)
137+
if (util.inspect(processFilePath).indexOf(util.inspect(p)) == -1) {
138+
processFilePath.push(p)
139+
}
132140
} catch (e) {
133141
console.error(e)
134142
}

vue-transformations/index.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ const transformationMap: {
1818
'remove-listeners': require('./remove-listeners')
1919
}
2020

21-
export const excludedVueTransformations = [
22-
'v-bind-order-sensitive'
23-
]
21+
export const excludedVueTransformations = ['v-bind-order-sensitive']
2422

2523
export default transformationMap

0 commit comments

Comments
 (0)