use sane version of split

This commit is contained in:
Domen Kožar 2019-10-01 12:10:07 +02:00
commit c97af141f3
No known key found for this signature in database
GPG key ID: C2FFBCAFD2C24246
3 changed files with 15 additions and 7 deletions

View file

@ -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}`);

View file

@ -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 != "")
}