Skip to content

Commit 891cf43

Browse files
committed
Update to 0.0.3
1 parent 9f0d4b5 commit 891cf43

File tree

8 files changed

+56
-27
lines changed

8 files changed

+56
-27
lines changed

.vscodeignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ vsc-extension-quickstart.md
77
**/jsconfig.json
88
**/*.map
99
**/.eslintrc.json
10+
image/demo.gif
11+
image/ctrlshiftp.png

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ Replace codes line by line with regex for target files
66

77
<img src="./image/demo.gif" />
88

9-
## Development environment
9+
## Environment
1010

11-
Tested on `Windows 10`, `macos Catalina`
11+
Tested on `Windows 10`, `macos`
1212

1313
## How to install
1414

15-
Search this plugin in vscode's market place.
15+
Search this plugin in vscode's [marketplace](https://marketplace.visualstudio.com/items?itemName=jopemachine.code-replacer).
1616

1717
Or download and import vsix file.
1818

code-replacer-0.0.2.vsix

-28.5 MB
Binary file not shown.

code-replacer-0.0.3.vsix

6.39 MB
Binary file not shown.

constant.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
module.exports = {
22
UIString: {
33
TYPE_INPUT: '[*] Type input.',
4-
EXIT: '[*] Exit the extension.'
4+
EXIT: '[*] Exit the extension.',
5+
FETCH_CSVS: '[*] Fetch and show all csv files from current directory.',
6+
ENTER_CSV_PATH: '[*] Enter csv path manually.',
7+
NO_CSV: '[*] Do not use csv.'
58
}
69
}

extension.js

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,33 +115,57 @@ const activate = (context) => {
115115
process.platform === 'win32'
116116
? replaceAll(__dirname, '\\', '\\\\')
117117
: __dirname
118+
118119
const codeReplacerPath = `${dirName}${pathSep}node_modules${pathSep}code-replacer${pathSep}dist`
119120
const binPath = `${codeReplacerPath}${pathSep}index.js`
120121
const envPath = `${codeReplacerPath}${pathSep}${'.env'}`
121122
const usageLogPath = `${codeReplacerPath}${pathSep}usageLog.json`
122123
const workspaceName = vscode.workspace.name
123124
const workspacePath = vscode.workspace.rootPath
124-
const csvFiles = await findFiles({
125-
dir: workspacePath,
126-
ext: 'csv'
127-
})
128-
const selectedCSV = await getQuickPick({
129-
items: [UIString.EXIT, ...csvFiles],
130-
placeHolder: 'Select your csv file or type esc to pass csv option.'
125+
126+
const csvSelectOpt = await getQuickPick({
127+
items: [
128+
UIString.FETCH_CSVS,
129+
UIString.ENTER_CSV_PATH,
130+
UIString.NO_CSV,
131+
UIString.EXIT
132+
],
133+
placeHolder: 'Select a method to handle csv option'
131134
})
132135

133-
if (!selectedCSV) {
134-
vscode.window.showInformationMessage('csv option is passed.')
135-
} else if (selectedCSV === UIString.EXIT) {
136-
vscode.window.showInformationMessage(UIString.EXIT)
137-
return
136+
let selectedCSV
137+
138+
switch (csvSelectOpt) {
139+
case UIString.ENTER_CSV_PATH:
140+
selectedCSV = await getInput({ placeHolder: 'Enter csv file path.' })
141+
break
142+
case UIString.FETCH_CSVS: {
143+
const csvFiles = await findFiles({
144+
dir: workspacePath,
145+
ext: 'csv'
146+
})
147+
selectedCSV = await getQuickPick({
148+
items: [UIString.EXIT, ...csvFiles],
149+
placeHolder: 'Select your csv file or type esc to pass csv option.'
150+
})
151+
}
152+
break
153+
// selectedCSV is undefined when NO CSV is selected
154+
case UIString.NO_CSV:
155+
vscode.window.showInformationMessage('csv option is passed.')
156+
break
157+
case UIString.EXIT:
158+
vscode.window.showErrorMessage(UIString.EXIT)
159+
return
160+
default:
161+
break
138162
}
139163

140164
const flags = {
141-
src: currentlyOpenTabfilePath,
142-
csv: selectedCSV
165+
src: currentlyOpenTabfilePath
143166
}
144167

168+
selectedCSV && (flags.csv = selectedCSV)
145169
flags.template = await handleTemplate({ usageLogPath })
146170

147171
if (!flags.template) {

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Replace codes line by line with regex for target files",
55
"author": "jopemachine",
66
"publisher": "jopemachine",
7-
"version": "0.0.2",
7+
"version": "0.0.3",
88
"license": "MIT",
99
"engines": {
1010
"vscode": "^1.50.0"
@@ -74,6 +74,6 @@
7474
},
7575
"dependencies": {
7676
"recursive-readdir": "^2.2.2",
77-
"code-replacer": "0.0.5"
77+
"code-replacer": "0.0.9"
7878
}
7979
}

0 commit comments

Comments
 (0)