Skip to content

Commit

Permalink
fix(index): set default cli name and version if empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Feb 22, 2025
1 parent d9e95ce commit 2ce39b5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jobs:

- name: Run action
uses: ./
with:
version: ''
name: ''

- name: Get version
run: ollama --version
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/__snapshots__/utils.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,41 @@ exports[`getBinaryPath when OS is "win32" returns CLI filepath 1`] = `"directory
exports[`getDownloadObject when OS is "darwin" and arch is "arm64" gets download object 1`] = `
{
"binaryDirectory": "",
"url": "https://ollama.com/download/ollama-darwin.tgz?version=0.5.11",
"url": "https://ollama.com/download/ollama-darwin.tgz?version=0.5.10",
}
`;

exports[`getDownloadObject when OS is "darwin" and arch is "x64" gets download object 1`] = `
{
"binaryDirectory": "",
"url": "https://ollama.com/download/ollama-darwin.tgz?version=0.5.11",
"url": "https://ollama.com/download/ollama-darwin.tgz?version=0.5.10",
}
`;

exports[`getDownloadObject when OS is "linux" and arch is "arm64" gets download object 1`] = `
{
"binaryDirectory": "bin",
"url": "https://ollama.com/download/ollama-linux-arm64.tgz?version=0.5.11",
"url": "https://ollama.com/download/ollama-linux-arm64.tgz?version=0.5.10",
}
`;

exports[`getDownloadObject when OS is "linux" and arch is "x64" gets download object 1`] = `
{
"binaryDirectory": "bin",
"url": "https://ollama.com/download/ollama-linux-amd64.tgz?version=0.5.11",
"url": "https://ollama.com/download/ollama-linux-amd64.tgz?version=0.5.10",
}
`;

exports[`getDownloadObject when OS is "win32" and arch is "arm64" gets download object 1`] = `
{
"binaryDirectory": "",
"url": "https://ollama.com/download/ollama-windows-arm64.zip?version=0.5.11",
"url": "https://ollama.com/download/ollama-windows-arm64.zip?version=0.5.10",
}
`;

exports[`getDownloadObject when OS is "win32" and arch is "x64" gets download object 1`] = `
{
"binaryDirectory": "",
"url": "https://ollama.com/download/ollama-windows-amd64.zip?version=0.5.11",
"url": "https://ollama.com/download/ollama-windows-amd64.zip?version=0.5.10",
}
`;
11 changes: 7 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ import path from 'path';

import { getBinaryPath, getDownloadObject } from './utils';

const DEFAULT_VERSION = '0.5.11';
const DEFAULT_NAME = 'ollama';

export async function run() {
try {
// Get the version and name of the tool to be installed
const cliVersion = getInput('version');
const cliName = getInput('name');
const cliVersion = getInput('version') || DEFAULT_VERSION;
const cliName = getInput('name') || DEFAULT_NAME;
const toolName = cliName;

// Find previously cached directory (if applicable)
Expand All @@ -40,9 +43,9 @@ export async function run() {
binaryPath = getBinaryPath(binaryDirectory, cliName);

// Rename the binary
if (cliName !== 'ollama') {
if (cliName !== DEFAULT_NAME) {
await exec('mv', [
getBinaryPath(binaryDirectory, 'ollama'),
getBinaryPath(binaryDirectory, DEFAULT_NAME),
binaryPath,
]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const table = platforms.reduce(

describe('getDownloadObject', () => {
describe.each(table)('when OS is %p and arch is %p', (os, arch) => {
const version = '0.5.11';
const version = '0.5.10';

beforeEach(() => {
jest.resetAllMocks();
Expand Down

0 comments on commit 2ce39b5

Please sign in to comment.