-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup
37 lines (28 loc) · 956 Bytes
/
setup
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
var app = Application.currentApplication();
app.includeStandardAdditions = true;
function prompt(text, defaultAnswer) {
var options = { defaultAnswer: defaultAnswer || '' }
try {
return app.displayDialog(text, options).textReturned
} catch (e) {
return ""
}
}
var project = ""
while (project == "") {
project = prompt("What project do you want to use?", "");
}
console.log("Using project "+project)
var context = ""
while (context == "") {
context = prompt("What context do you want to use?", "");
}
console.log("Using context "+context)
var text = "{\"project\":\""+project+"\", \"context\":\""+context+"\"}"
var openedFile = app.openForAccess(Path("./config.json"), { writePermission: true });
// Clear the file if content should be overwritten
app.setEof(openedFile, { to: 0 })
// Write the new content to the file
app.write(text, { to: openedFile, startingAt: app.getEof(openedFile) })
// Close the file
app.closeAccess(openedFile)