smipper 16.0.0 → 17.0.0
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 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -62,9 +62,44 @@ if (!stack) {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
function findFile(dir, fn) {
|
|
66
|
+
const list = fs.readdirSync(dir);
|
|
67
|
+
for (let file of list) {
|
|
68
|
+
const match = (file === fn);
|
|
69
|
+
file = dir + '/' + file;
|
|
70
|
+
const stat = fs.statSync(file);
|
|
71
|
+
if (stat && stat.isDirectory()) {
|
|
72
|
+
const ret = findFile(file, fn);
|
|
73
|
+
if (ret) {
|
|
74
|
+
return ret;
|
|
75
|
+
}
|
|
76
|
+
} else if (match) {
|
|
77
|
+
return "file://" + file;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function rewriteLocalControl(url)
|
|
84
|
+
{
|
|
85
|
+
const found = findFile(process.cwd(), path.basename(url.substring(6)));
|
|
86
|
+
if (found)
|
|
87
|
+
return found;
|
|
88
|
+
throw new Error("Couldn't resolve localcontrol " + url);
|
|
89
|
+
}
|
|
90
|
+
|
|
65
91
|
function load(path)
|
|
66
92
|
{
|
|
67
93
|
return new Promise((resolve, reject) => {
|
|
94
|
+
if (path.startsWith("http://localcontrol.netflix.com/")) {
|
|
95
|
+
try {
|
|
96
|
+
path = rewriteLocalControl(path);
|
|
97
|
+
} catch (err) {
|
|
98
|
+
reject(err);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
68
103
|
if (path.startsWith("file:///")) {
|
|
69
104
|
try {
|
|
70
105
|
resolve(fs.readFileSync(path.substr(7), "utf8"));
|
|
@@ -73,14 +108,12 @@ function load(path)
|
|
|
73
108
|
}
|
|
74
109
|
return;
|
|
75
110
|
}
|
|
111
|
+
|
|
76
112
|
if (!path.startsWith("http://") && !path.startsWith("https://")) {
|
|
77
113
|
reject(new Error("Not a url"));
|
|
78
114
|
return;
|
|
79
115
|
}
|
|
80
|
-
|
|
81
|
-
reject(new Error("No need to resolve this one"));
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
116
|
+
|
|
84
117
|
let retryIndex = 0;
|
|
85
118
|
async function get()
|
|
86
119
|
{
|