expose-kit 0.2.4 → 0.2.5
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/dist/index.js +10 -4
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -131,6 +131,14 @@ import { parse as parse2 } from "@babel/parser";
|
|
|
131
131
|
import traverse from "@babel/traverse";
|
|
132
132
|
import generate from "@babel/generator";
|
|
133
133
|
import loading2 from "loading-cli";
|
|
134
|
+
|
|
135
|
+
// utils/babel/patchTraverse.ts
|
|
136
|
+
import "@babel/traverse";
|
|
137
|
+
var patchTraverse = (traverse2) => {
|
|
138
|
+
return traverse2.default;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// commands/scope-safe/index.ts
|
|
134
142
|
var createDefaultOutputPath = (inputPath) => {
|
|
135
143
|
const ext = extname(inputPath);
|
|
136
144
|
if (!ext) {
|
|
@@ -142,7 +150,7 @@ var createDefaultOutputPath = (inputPath) => {
|
|
|
142
150
|
var renameBindingsByScope = (code, filename) => {
|
|
143
151
|
const ast = parse2(code, createParseOptions(filename));
|
|
144
152
|
const renamedBindings = /* @__PURE__ */ new Set();
|
|
145
|
-
traverse(ast, {
|
|
153
|
+
patchTraverse(traverse)(ast, {
|
|
146
154
|
Scopable(path) {
|
|
147
155
|
for (const [name, binding] of Object.entries(path.scope.bindings)) {
|
|
148
156
|
if (renamedBindings.has(binding)) {
|
|
@@ -176,9 +184,7 @@ var scope_safe_default = createCommand((program2) => {
|
|
|
176
184
|
try {
|
|
177
185
|
const fileContent = readFileSync2(filename, "utf8");
|
|
178
186
|
const defaultOutputPath = createDefaultOutputPath(filename);
|
|
179
|
-
|
|
180
|
-
"Enter the output file path:"
|
|
181
|
-
) || "").trim() ?? defaultOutputPath;
|
|
187
|
+
const outputPath = options.output ?? (await createPrompt("Enter the output file path:") || "").trim() ?? defaultOutputPath;
|
|
182
188
|
const loader = loading2("Renaming variables by scope...").start();
|
|
183
189
|
try {
|
|
184
190
|
const output = renameBindingsByScope(fileContent, filename);
|
package/dist/package.json
CHANGED