-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
35 lines (28 loc) · 835 Bytes
/
test.js
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
const inputText = `... (your input text) ...`;
// Split the inputText into lines.
const lines = inputText.split('\n');
// Initialize an array to store the matched commands.
const matchedCommands = [];
// Iterate through each line.
let isRunStep = false;
for (const line of lines) {
// Check if this is the start of a "run" step.
if (line.trim() === '- name: Run code style tests') {
isRunStep = true;
continue;
}
// Check if this is the end of the "run" step.
if (isRunStep && line.trim().startsWith('run: |')) {
isRunStep = false;
continue;
}
// If inside a "run" step, add the line to the matchedCommands array.
if (isRunStep) {
const command = line.trim();
if (command) {
matchedCommands.push(command);
}
}
}
// Output the extracted commands.
console.log(matchedCommands);