@infomiho/buzz-cli 0.1.0 → 0.2.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/dist/cli.js +12 -6
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -59,10 +59,16 @@ async function deploy(directory, subdomain) {
|
|
|
59
59
|
console.error(`Error: '${directory}' is not a directory`);
|
|
60
60
|
process.exit(1);
|
|
61
61
|
}
|
|
62
|
-
// Check for CNAME file if no subdomain specified
|
|
63
|
-
const
|
|
64
|
-
if (!subdomain && existsSync(
|
|
65
|
-
subdomain = readFileSync(
|
|
62
|
+
// Check for CNAME file if no subdomain specified (check cwd first, then directory)
|
|
63
|
+
const cwdCnamePath = join(process.cwd(), "CNAME");
|
|
64
|
+
if (!subdomain && existsSync(cwdCnamePath)) {
|
|
65
|
+
subdomain = readFileSync(cwdCnamePath, "utf-8").trim();
|
|
66
|
+
}
|
|
67
|
+
else if (!subdomain) {
|
|
68
|
+
const dirCnamePath = join(directory, "CNAME");
|
|
69
|
+
if (existsSync(dirCnamePath)) {
|
|
70
|
+
subdomain = readFileSync(dirCnamePath, "utf-8").trim();
|
|
71
|
+
}
|
|
66
72
|
}
|
|
67
73
|
console.log(`Zipping ${directory}...`);
|
|
68
74
|
const zipBuffer = await createZipBuffer(directory);
|
|
@@ -90,9 +96,9 @@ async function deploy(directory, subdomain) {
|
|
|
90
96
|
const data = await response.json();
|
|
91
97
|
if (response.ok) {
|
|
92
98
|
console.log(`Deployed to ${data.url}`);
|
|
93
|
-
// Save subdomain to CNAME file
|
|
99
|
+
// Save subdomain to CNAME file in cwd
|
|
94
100
|
const deployedSubdomain = new URL(data.url).hostname.split(".")[0];
|
|
95
|
-
writeFileSync(
|
|
101
|
+
writeFileSync(cwdCnamePath, deployedSubdomain + "\n");
|
|
96
102
|
}
|
|
97
103
|
else {
|
|
98
104
|
console.error(`Error: ${data.error || "Unknown error"}`);
|