-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextension.js
More file actions
53 lines (44 loc) · 1.48 KB
/
extension.js
File metadata and controls
53 lines (44 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const vscode = require('vscode');
const { createHandler, renameHandler } = require('./src/handlers');
const { isTestFile } = require('./src/helpers');
function activate(context) {
vscode.window.showInformationMessage("Flutter Mimic Active!");
let nextActionIsRename = false;
let watcher = vscode.workspace.createFileSystemWatcher('**/*')
watcher.ignoreCreateEvents = false;
watcher.ignoreChangeEvents = true;
watcher.ignoreDeleteEvents = true;
watcher.onDidCreate((e) => {
if (nextActionIsRename) {
nextActionIsRename = false;
} else {
if (!e.path.endsWith('test.dart')) {
vscode.window.showInformationMessage(
"Flutter Mimic: You just created a new Dart file. Do you want to create a mirrored test file?",
...["Yes", "No"]
).then((answer) => {
answer === "Yes"
? createHandler(e, () => { vscode.window.showInformationMessage("Flutter Mimic: File create!") })
: vscode.window.showInformationMessage("Flutter Mimic: Nothing done!")
})
}
}
})
vscode.workspace.onDidRenameFiles((e) => {
nextActionIsRename = true;
e.files.forEach((file) => {
renameHandler(file);
})
vscode.window.showInformationMessage("Adjusment made");
})
vscode.workspace.onDidDeleteFiles((e) => {
vscode.window.showInformationMessage("Flutter Mimic: Files arent deleted automatic.");
});
context.subscriptions.push(watcher);
}
// this method is called when your extension is deactivated
function deactivate() { }
module.exports = {
activate,
deactivate
}