mirror of
https://github.com/expo/expo-github-action.git
synced 2026-11-15 17:32:45 -10:00
fix: use which instead of npx to authenticate (#147)
* fix: use which instead of npx to authenticate * chore: test both with and without cache * chore: update test for authentication
This commit is contained in:
1 parent
439ff4c9aa
commit
c5d2c0f8c0
4 files changed
+17
-6
No files matched your search
@@ -17,6 +17,9 @@ jobs:
|
||||
- macos-latest
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
cache:
|
||||
- true
|
||||
- false
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: 🏗 Setup repo
|
||||
@@ -26,9 +29,9 @@ jobs:
|
||||
uses: ./
|
||||
with:
|
||||
eas-version: latest
|
||||
eas-cache: true
|
||||
eas-cache: ${{ matrix.cache }}
|
||||
expo-version: latest
|
||||
expo-cache: true
|
||||
expo-cache: ${{ matrix.cache }}
|
||||
token: ${{ secrets.EXPO_TOKEN }}
|
||||
|
||||
- name: 🧪 EAS installed
|
||||
|
||||
@@ -64755,6 +64755,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.executeAction = exports.expoAuthenticate = exports.patchWatchers = exports.installToolFromPackage = exports.toolPath = exports.tempPath = exports.cacheTool = exports.findTool = void 0;
|
||||
const core_1 = __nccwpck_require__(2186);
|
||||
const exec_1 = __nccwpck_require__(1514);
|
||||
const io_1 = __nccwpck_require__(7436);
|
||||
const os_1 = __importDefault(__nccwpck_require__(2037));
|
||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||
var tool_cache_1 = __nccwpck_require__(7784);
|
||||
@@ -64825,7 +64826,7 @@ async function expoAuthenticate(token, cli) {
|
||||
(0, core_1.info)(`Skipped token validation: no CLI installed, can't run 'whoami'.`);
|
||||
}
|
||||
else {
|
||||
await (0, exec_1.exec)('npx --no-install', [cli, 'whoami'], {
|
||||
await (0, exec_1.exec)(await (0, io_1.which)(cli), ['whoami'], {
|
||||
env: { ...process.env, EXPO_TOKEN: token },
|
||||
});
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
import { addPath, exportVariable, info, setFailed, warning } from '@actions/core';
|
||||
import { exec } from '@actions/exec';
|
||||
import { which } from '@actions/io';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -71,7 +72,7 @@ export async function expoAuthenticate(token: string, cli?: 'expo' | 'eas'): Pro
|
||||
if (!cli) {
|
||||
info(`Skipped token validation: no CLI installed, can't run 'whoami'.`);
|
||||
} else {
|
||||
await exec('npx --no-install', [cli, 'whoami'], {
|
||||
await exec(await which(cli), ['whoami'], {
|
||||
env: { ...process.env, EXPO_TOKEN: token },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as exec from '@actions/exec';
|
||||
import * as io from '@actions/io';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -15,6 +16,7 @@ import { resetEnv, setEnv, setPlatform, resetPlatform } from './utils';
|
||||
|
||||
jest.mock('@actions/core');
|
||||
jest.mock('@actions/exec');
|
||||
jest.mock('@actions/io');
|
||||
|
||||
describe(tempPath, () => {
|
||||
afterEach(resetEnv);
|
||||
@@ -93,15 +95,19 @@ describe(expoAuthenticate, () => {
|
||||
});
|
||||
|
||||
it('validates EXPO_TOKEN with expo-cli', async () => {
|
||||
jest.mocked(io.which).mockResolvedValue('expo');
|
||||
await expoAuthenticate('faketoken', 'expo');
|
||||
expect(exec.exec).toBeCalledWith('npx --no-install', ['expo', 'whoami'], {
|
||||
expect(io.which).toBeCalledWith('expo');
|
||||
expect(exec.exec).toBeCalledWith('expo', ['whoami'], {
|
||||
env: expect.objectContaining({ EXPO_TOKEN: 'faketoken' }),
|
||||
});
|
||||
});
|
||||
|
||||
it('validates EXPO_TOKEN with eas-cli', async () => {
|
||||
jest.mocked(io.which).mockResolvedValue('eas');
|
||||
await expoAuthenticate('faketoken', 'eas');
|
||||
expect(exec.exec).toBeCalledWith('npx --no-install', ['eas', 'whoami'], {
|
||||
expect(io.which).toBeCalledWith('eas');
|
||||
expect(exec.exec).toBeCalledWith('eas', ['whoami'], {
|
||||
env: expect.objectContaining({ EXPO_TOKEN: 'faketoken' }),
|
||||
});
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user