testdriverai 4.0.34 → 4.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +37 -2
- package/lib/sdk.js +6 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -100,14 +100,49 @@ console.log('')
|
|
|
100
100
|
// individual run ID for this session
|
|
101
101
|
let runID = new Date().getTime();
|
|
102
102
|
|
|
103
|
+
function fileCompleter(line) {
|
|
104
|
+
line = line.slice(5); // remove /run
|
|
105
|
+
const lastSepIndex = line.lastIndexOf(path.sep);
|
|
106
|
+
let dir;
|
|
107
|
+
let partial;
|
|
108
|
+
if (lastSepIndex === -1) {
|
|
109
|
+
dir = '.';
|
|
110
|
+
partial = line;
|
|
111
|
+
}
|
|
112
|
+
else{
|
|
113
|
+
dir = line.slice(0, lastSepIndex + 1);
|
|
114
|
+
partial = line.slice(lastSepIndex + 1);
|
|
115
|
+
}
|
|
116
|
+
try{
|
|
117
|
+
const dirPath = path.resolve(process.cwd(), dir);
|
|
118
|
+
|
|
119
|
+
let files = fs.readdirSync(dirPath);
|
|
120
|
+
files = files.map(file => {
|
|
121
|
+
const fullFilePath = path.join(dirPath, file);
|
|
122
|
+
const fileStats = fs.statSync(fullFilePath);
|
|
123
|
+
return file + (fileStats.isDirectory() ? path.sep : ''); // add path.sep for dir
|
|
124
|
+
});
|
|
125
|
+
const matches = files.filter(file => file.startsWith(partial));
|
|
126
|
+
|
|
127
|
+
return [matches.length ? matches : files, partial];
|
|
128
|
+
}
|
|
129
|
+
catch(err){
|
|
130
|
+
return [[], partial];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
103
134
|
function completer(line) {
|
|
104
135
|
let completions = '/summarize /save /run /quit /explore /assert /undo /manual'.split(' ')
|
|
105
|
-
|
|
136
|
+
if(line.startsWith('/run ')){
|
|
137
|
+
return fileCompleter(line);
|
|
138
|
+
}
|
|
139
|
+
else{
|
|
106
140
|
completions.concat(tasks)
|
|
107
141
|
|
|
108
142
|
var hits = completions.filter(function(c) { return c.indexOf(line) == 0 })
|
|
109
143
|
// show all completions if none found
|
|
110
|
-
|
|
144
|
+
return [hits.length ? hits : completions, line]
|
|
145
|
+
}
|
|
111
146
|
}
|
|
112
147
|
|
|
113
148
|
if (!fs.existsSync(commandHistoryFile)) {
|
package/lib/sdk.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
// custom "sdk" for calling our API
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
let root = "https://replayable-api-production.herokuapp.com";
|
|
4
|
+
|
|
5
|
+
if (process.env['DEV']) {
|
|
6
|
+
root = "https://replayable-dev-ian-mac-m1-16.ngrok.io";
|
|
7
|
+
}
|
|
8
|
+
|
|
5
9
|
const chalk = require('chalk');
|
|
6
10
|
const axios = require('axios');
|
|
7
11
|
const session = require('./session')
|