diff --git a/README.md b/README.md index 47242f9..96cba7b 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ yarn global add verceler After installing verceler, you can use it via the command line. Here are some common commands and options: ```sh -verceler --vt --gt [options] +verceler -vt -gt [options] ``` ### Options diff --git a/src/index.js b/src/index.js index 61c21b6..b831be9 100755 --- a/src/index.js +++ b/src/index.js @@ -23,8 +23,8 @@ async function main() { npm.installVercelCli(); - vercelManager.linkProject(); vercelManager.setVercelToken(vercelToken); + vercelManager.linkProject(); const envList = cliOptions.getEnvList(); diff --git a/src/utils/VercelManager.js b/src/utils/VercelManager.js index e49105b..2ae5652 100644 --- a/src/utils/VercelManager.js +++ b/src/utils/VercelManager.js @@ -20,7 +20,7 @@ class VercelManager { linkProject() { try { - execSync("vercel link --yes"); + execSync(`vercel link --yes --token ${this.vercelToken}`); } catch (error) { console.error("Failed to link Vercel project:", error.message); } diff --git a/tests/utils/VercelManager.test.js b/tests/utils/VercelManager.test.js index 4ea5590..895eb71 100644 --- a/tests/utils/VercelManager.test.js +++ b/tests/utils/VercelManager.test.js @@ -10,6 +10,7 @@ jest.mock("fs"); jest.mock("path"); jest.mock("progress"); jest.mock("cross-spawn"); +jest.mock(); describe("VercelManager", () => { beforeEach(() => { @@ -34,19 +35,24 @@ describe("VercelManager", () => { it("should link the Vercel project", () => { execSync.mockReturnValue(undefined); + vercelManager.setVercelToken("mock_token"); vercelManager.linkProject(); - expect(execSync).toHaveBeenCalledWith("vercel link --yes"); + expect(execSync).toHaveBeenCalledWith( + "vercel link --yes --token mock_token" + ); }); it("should handle error when linking the Vercel project fails", () => { execSync.mockImplementation(() => { throw new Error("Linking failed"); }); - + vercelManager.setVercelToken("mock_token"); vercelManager.linkProject(); - expect(execSync).toHaveBeenCalledWith("vercel link --yes"); + expect(execSync).toHaveBeenCalledWith( + "vercel link --yes --token mock_token" + ); expect(console.error).toHaveBeenCalledWith( "Failed to link Vercel project:", "Linking failed"