Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 533a947

Browse files
committed
Changing ts files to js in parser to keep it consistent
1 parent 9b464b8 commit 533a947

File tree

10 files changed

+620
-775
lines changed

10 files changed

+620
-775
lines changed

packages/luis/src/commands/luis/generate/cs.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import {CLIError, Command, flags} from '@microsoft/bf-cli-command'
22
import {camelCase, upperFirst} from 'lodash'
33
import * as path from 'path'
44

5-
import {LuisToCsConverter} from '../../../parser/converters/luis-to-cs-converter'
6-
5+
const LuisToCsConverter = require('./../../../parser/converters/luistocsconverter')
76
const file = require('./../../../utils/filehelper')
87
const fs = require('fs-extra')
98

packages/luis/src/commands/luis/generate/ts.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import {CLIError, Command, flags} from '@microsoft/bf-cli-command'
22
import {camelCase, kebabCase, upperFirst} from 'lodash'
33
import * as path from 'path'
44

5-
import {LuisToTsConverter} from '../../../parser/converters/luis-to-ts-converter'
6-
5+
const LuisToTsConverter = require('./../../../parser/converters/luistotsconverter')
76
const file = require('./../../../utils/filehelper')
87
const fs = require('fs-extra')
98

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
const fs = require("fs");
2+
class Writer {
3+
constructor() {
4+
this.indentSize = 4;
5+
this.indentLevel = 0;
6+
this.outputStream = undefined;
7+
}
8+
async setOutputStream(outputPath) {
9+
const ConsoleStream = require('console-stream');
10+
const stream = outputPath ? fs.createWriteStream(outputPath) : ConsoleStream();
11+
const streamPromise = new Promise((resolve) => {
12+
if (stream instanceof fs.WriteStream) {
13+
stream.once('ready', (_fd) => {
14+
this.outputStream = stream;
15+
resolve();
16+
});
17+
}
18+
else {
19+
this.outputStream = stream;
20+
resolve();
21+
}
22+
});
23+
const timeoutPromise = new Promise((resolve) => {
24+
setTimeout(resolve, 2000);
25+
this.outputStream = stream;
26+
});
27+
return Promise.race([streamPromise, timeoutPromise]).then(() => {
28+
});
29+
}
30+
increaseIndentation() {
31+
this.indentLevel += this.indentSize;
32+
}
33+
decreaseIndentation() {
34+
this.indentLevel -= this.indentSize;
35+
}
36+
write(str) {
37+
this.outputStream.write(str);
38+
}
39+
writeLine(str = '') {
40+
if (typeof str === 'string') {
41+
this.write(str + '\n');
42+
}
43+
else {
44+
str.forEach(line => {
45+
this.write(line + '\n');
46+
});
47+
}
48+
}
49+
writeIndented(str) {
50+
let writeFunction = (text) => {
51+
for (let index = 0; index < this.indentLevel; index++) {
52+
this.write(' ');
53+
}
54+
this.write(text);
55+
};
56+
writeFunction.bind(this);
57+
if (typeof str === 'string') {
58+
writeFunction(str);
59+
}
60+
else {
61+
str.forEach(line => {
62+
writeFunction(line);
63+
});
64+
}
65+
}
66+
writeLineIndented(lines) {
67+
if (typeof lines === 'string') {
68+
this.writeIndented(lines + '\n');
69+
}
70+
else {
71+
lines.forEach(line => {
72+
this.writeIndented(line + '\n');
73+
});
74+
}
75+
}
76+
async closeOutputStream() {
77+
this.outputStream.end();
78+
const streamPromise = new Promise((resolve) => {
79+
if (this.outputStream instanceof fs.WriteStream) {
80+
this.outputStream.on('finish', (_fd) => {
81+
resolve();
82+
});
83+
}
84+
else {
85+
resolve();
86+
}
87+
});
88+
const timeoutPromise = new Promise((resolve) => {
89+
setTimeout(resolve, 1000);
90+
});
91+
return Promise.race([streamPromise, timeoutPromise]).then(() => {
92+
this.outputStream = undefined;
93+
});
94+
}
95+
}
96+
module.exports = Writer;

packages/luis/src/parser/converters/helpers/writer.ts

Lines changed: 0 additions & 104 deletions
This file was deleted.

0 commit comments

Comments
 (0)