mirror of
https://codeberg.org/icewind/attic-action.git
synced 2026-06-03 17:44:07 +02:00
use sane version of split
This commit is contained in:
parent
4db446a512
commit
c97af141f3
3 changed files with 15 additions and 7 deletions
|
|
@ -1,8 +1,13 @@
|
|||
import {extrasperse} from '../src/utils'
|
||||
import {extrasperse, saneSplit} from '../src/utils'
|
||||
|
||||
test('extrasperse', async() => {
|
||||
expect(extrasperse('-A', ["foo", "bar"])).toEqual(["-A", "foo", "-A", "bar"]);
|
||||
expect(extrasperse('-A', [])).toEqual([])
|
||||
expect(extrasperse('-A', [])).toEqual([]);
|
||||
});
|
||||
|
||||
test('saneSplit', async() => {
|
||||
expect(saneSplit("", /\s+/)).toEqual([]);
|
||||
expect(saneSplit("foo bar", /\s+/)).toEqual(["foo", "bar"]);
|
||||
})
|
||||
|
||||
// TODO: hopefully github actions will support integration tests
|
||||
|
|
@ -3,7 +3,7 @@ import * as exec from '@actions/exec';
|
|||
import * as tc from '@actions/tool-cache';
|
||||
import {homedir} from 'os';
|
||||
import {existsSync} from 'fs';
|
||||
import {extrasperse} from './utils';
|
||||
import {extrasperse, saneSplit} from './utils';
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
|
|
@ -50,12 +50,12 @@ async function run() {
|
|||
},
|
||||
}
|
||||
};
|
||||
const args = extrasperse('-A', attributes.split(/\s/)).concat([file || "default.nix"]);
|
||||
const args = extrasperse('-A', saneSplit(attributes, /\s/)).concat([file || "default.nix"]);
|
||||
await exec.exec('nix-build', args, options);
|
||||
core.endGroup()
|
||||
|
||||
core.startGroup(`Pushing to Cachix ` + cachixPush);
|
||||
await exec.exec('cachix', ['push', cachixPush].concat(paths.split(/\s/).join(' ')));
|
||||
await exec.exec('cachix', ['push', cachixPush].concat(saneSplit(paths, /\s/).join(' ')));
|
||||
core.endGroup()
|
||||
} catch (error) {
|
||||
core.setFailed(`Action failed with error: ${error}`);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
export function extrasperse (elem: string, array: string[]) {
|
||||
export function extrasperse (elem: string, array: string[]): string[] {
|
||||
const init: string[] = [];
|
||||
return array.reduce((r, a) => r.concat(elem, a), init)
|
||||
};
|
||||
|
||||
|
||||
export function saneSplit (str: string, separator): string[] {
|
||||
return str.split(separator).filter(word => word != "")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue