wrec 0.35.2 → 0.35.4
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/package.json +1 -1
- package/scripts/declare.js +10 -10
- package/scripts/used-by.js +1 -1
package/package.json
CHANGED
package/scripts/declare.js
CHANGED
|
@@ -83,7 +83,12 @@ function analyzeSourceFile(sourceFile) {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
// Builds the `declare` block that should appear after `static properties`.
|
|
86
|
-
function buildDeclareBlock(
|
|
86
|
+
function buildDeclareBlock(
|
|
87
|
+
sourceFile,
|
|
88
|
+
classNode,
|
|
89
|
+
propertiesMember,
|
|
90
|
+
declareLines
|
|
91
|
+
) {
|
|
87
92
|
const {text} = sourceFile;
|
|
88
93
|
const memberIndent = getIndent(text, propertiesMember.getStart(sourceFile));
|
|
89
94
|
const startIndex = classNode.members.indexOf(propertiesMember) + 1;
|
|
@@ -105,9 +110,7 @@ function buildDeclareBlock(sourceFile, classNode, propertiesMember, declareLines
|
|
|
105
110
|
return nextMember ? `\n\n${nextIndent}` : '\n';
|
|
106
111
|
}
|
|
107
112
|
|
|
108
|
-
const content = declareLines
|
|
109
|
-
.map(line => `${memberIndent}${line}`)
|
|
110
|
-
.join('\n');
|
|
113
|
+
const content = declareLines.map(line => `${memberIndent}${line}`).join('\n');
|
|
111
114
|
return nextMember ? `\n${content}\n\n${nextIndent}` : `\n${content}\n`;
|
|
112
115
|
}
|
|
113
116
|
|
|
@@ -138,15 +141,12 @@ export function evaluateSourceFile(filePath, options = {}) {
|
|
|
138
141
|
|
|
139
142
|
// Determines what changes, if any, should be made in source file text.
|
|
140
143
|
export function evaluateSourceText(filePath, text) {
|
|
141
|
-
const scriptKind = filePath.endsWith('.ts')
|
|
142
|
-
? ts.ScriptKind.TS
|
|
143
|
-
: ts.ScriptKind.JS;
|
|
144
144
|
const sourceFile = ts.createSourceFile(
|
|
145
145
|
filePath,
|
|
146
146
|
text,
|
|
147
147
|
ts.ScriptTarget.Latest,
|
|
148
148
|
true,
|
|
149
|
-
|
|
149
|
+
ts.ScriptKind.TS
|
|
150
150
|
);
|
|
151
151
|
return analyzeSourceFile(sourceFile);
|
|
152
152
|
}
|
|
@@ -258,8 +258,8 @@ function validateFile(absFilePath) {
|
|
|
258
258
|
const stat = fs.statSync(absFilePath);
|
|
259
259
|
if (!stat.isFile()) throw new Error('Not a file');
|
|
260
260
|
|
|
261
|
-
if (!/\.
|
|
262
|
-
throw new Error('
|
|
261
|
+
if (!/\.ts$/.test(absFilePath)) {
|
|
262
|
+
throw new Error('declare statements can only be added in .ts files');
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
265
|
|
package/scripts/used-by.js
CHANGED
|
@@ -723,7 +723,7 @@ function validateFile(absFilePath) {
|
|
|
723
723
|
const stat = fs.statSync(absFilePath);
|
|
724
724
|
if (!stat.isFile()) throw new Error('Not a file');
|
|
725
725
|
|
|
726
|
-
if (!/\.(js|ts)$/.test(absFilePath)
|
|
726
|
+
if (!/\.(js|ts)$/.test(absFilePath)) {
|
|
727
727
|
throw new Error('Unsupported file type');
|
|
728
728
|
}
|
|
729
729
|
}
|