mirror of
https://codeberg.org/icewind/attic-action.git
synced 2026-06-03 17:44:07 +02:00
saneSplit -> nonEmptySplit
This commit is contained in:
parent
cea7883cb2
commit
34a3c66a7e
5 changed files with 21 additions and 21 deletions
|
|
@ -1,13 +1,13 @@
|
||||||
import {extrasperse, saneSplit} from '../src/strings'
|
import {prependEach, nonEmptySplit} from '../src/strings'
|
||||||
|
|
||||||
test('extrasperse', async() => {
|
test('prependEach', async() => {
|
||||||
expect(extrasperse('-A', ["foo", "bar"])).toEqual(["-A", "foo", "-A", "bar"]);
|
expect(prependEach('-A', ["foo", "bar"])).toEqual(["-A", "foo", "-A", "bar"]);
|
||||||
expect(extrasperse('-A', [])).toEqual([]);
|
expect(prependEach('-A', [])).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('saneSplit', async() => {
|
test('nonEmptySplit', async() => {
|
||||||
expect(saneSplit("", /\s+/)).toEqual([]);
|
expect(nonEmptySplit("", /\s+/)).toEqual([]);
|
||||||
expect(saneSplit("foo bar", /\s+/)).toEqual(["foo", "bar"]);
|
expect(nonEmptySplit("foo bar", /\s+/)).toEqual(["foo", "bar"]);
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO: hopefully github actions will support integration tests
|
// TODO: hopefully github actions will support integration tests
|
||||||
|
|
@ -50,11 +50,11 @@ function run() {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const args = strings_1.extrasperse('-A', strings_1.saneSplit(attributes, /\s/)).concat([file || "default.nix"]);
|
const args = strings_1.prependEach('-A', strings_1.nonEmptySplit(attributes, /\s/)).concat([file || "default.nix"]);
|
||||||
yield exec.exec('nix-build', args, options);
|
yield exec.exec('nix-build', args, options);
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
core.startGroup(`Cachix: pushing to ` + push);
|
core.startGroup(`Cachix: pushing to ` + push);
|
||||||
yield exec.exec('cachix', ['push', push].concat(strings_1.saneSplit(paths, /\s/).join(' ')));
|
yield exec.exec('cachix', ['push', push].concat(strings_1.nonEmptySplit(paths, /\s/).join(' ')));
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
function extrasperse(elem, array) {
|
function prependEach(elem, array) {
|
||||||
const init = [];
|
const init = [];
|
||||||
return array.reduce((r, a) => r.concat(elem, a), init);
|
return array.reduce((r, a) => r.concat(elem, a), init);
|
||||||
}
|
}
|
||||||
exports.extrasperse = extrasperse;
|
exports.prependEach = prependEach;
|
||||||
;
|
;
|
||||||
function saneSplit(str, separator) {
|
function nonEmptySplit(str, separator) {
|
||||||
return str.split(separator).filter(word => word != "");
|
return str.split(separator).filter(word => word != "");
|
||||||
}
|
}
|
||||||
exports.saneSplit = saneSplit;
|
exports.nonEmptySplit = nonEmptySplit;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
import {extrasperse, saneSplit} from './strings';
|
import {prependEach, nonEmptySplit} from './strings';
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
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);
|
await exec.exec('nix-build', args, options);
|
||||||
core.endGroup()
|
core.endGroup()
|
||||||
|
|
||||||
core.startGroup(`Cachix: pushing to ` + push);
|
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()
|
core.endGroup()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(`Action failed with error: ${error}`);
|
core.setFailed(`Action failed with error: ${error}`);
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
export function extrasperse (elem: string, array: string[]): string[] {
|
export function prependEach (elem: string, array: string[]): string[] {
|
||||||
const init: string[] = [];
|
const init: string[] = [];
|
||||||
return array.reduce((r, a) => r.concat(elem, a), init)
|
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 != "")
|
return str.split(separator).filter(word => word != "")
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue