saneSplit -> nonEmptySplit

This commit is contained in:
Domen Kožar 2019-10-03 13:26:42 +02:00
commit 34a3c66a7e
No known key found for this signature in database
GPG key ID: C2FFBCAFD2C24246
5 changed files with 21 additions and 21 deletions

View file

@ -1,6 +1,6 @@
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import {extrasperse, saneSplit} from './strings';
import {prependEach, nonEmptySplit} from './strings';
async function run() {
try {
@ -37,12 +37,12 @@ async function run() {
},
}
};
const args = extrasperse('-A', saneSplit(attributes, /\s/)).concat([file || "default.nix"]);
const args = prependEach('-A', nonEmptySplit(attributes, /\s/)).concat([file || "default.nix"]);
await exec.exec('nix-build', args, options);
core.endGroup()
core.startGroup(`Cachix: pushing to ` + push);
await exec.exec('cachix', ['push', push].concat(saneSplit(paths, /\s/).join(' ')));
await exec.exec('cachix', ['push', push].concat(nonEmptySplit(paths, /\s/).join(' ')));
core.endGroup()
} catch (error) {
core.setFailed(`Action failed with error: ${error}`);

View file

@ -1,8 +1,8 @@
export function extrasperse (elem: string, array: string[]): string[] {
const init: string[] = [];
return array.reduce((r, a) => r.concat(elem, a), init)
};
export function prependEach (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[] {
export function nonEmptySplit (str: string, separator): string[] {
return str.split(separator).filter(word => word != "")
}