diff --git a/packages/build/src/plugins/child/status.js b/packages/build/src/plugins/child/status.js index 79374f446a..4183b52d45 100644 --- a/packages/build/src/plugins/child/status.js +++ b/packages/build/src/plugins/child/status.js @@ -45,7 +45,7 @@ const validateShowArgs = function(showArgs) { } const validateStringArg = function([key, value]) { - if (typeof value !== 'string' || value.trim() === '') { + if (value !== undefined && (typeof value !== 'string' || value.trim() === '')) { throw new Error(`"${key}" property must be a non-empty string`) } } diff --git a/packages/build/tests/plugins/status/snapshots/tests.js.md b/packages/build/tests/plugins/status/snapshots/tests.js.md index dca74fd9f7..76adf4f31e 100644 --- a/packages/build/tests/plugins/status/snapshots/tests.js.md +++ b/packages/build/tests/plugins/status/snapshots/tests.js.md @@ -4,6 +4,50 @@ The actual snapshot is saved in `tests.js.snap`. Generated by [AVA](https://ava.li). +## utils.status.show() allow other fields to be optional + +> Snapshot 1 + + `␊ + ┌─────────────────────────────┐␊ + │ Netlify Build │␊ + └─────────────────────────────┘␊ + ␊ + > Version␊ + @netlify/build 1.0.0␊ + ␊ + > Flags␊ + repositoryRoot: /file/path␊ + ␊ + > Current directory␊ + /file/path␊ + ␊ + > Config file␊ + /file/path␊ + ␊ + > Resolved config␊ + plugins:␊ + - package: /file/path␊ + ␊ + > Context␊ + production␊ + ␊ + > Loading plugins␊ + - /file/path␊ + ␊ + ┌────────────────────────────────────┐␊ + │ 1. onInit command from /file/path │␊ + └────────────────────────────────────┘␊ + ␊ + ␊ + (/file/path onInit completed in 1ms)␊ + ␊ + ┌─────────────────────────────┐␊ + │ Netlify Build Complete │␊ + └─────────────────────────────┘␊ + ␊ + (Netlify Build completed in 1ms)` + ## utils.status.show() argument should be an object > Snapshot 1 @@ -587,26 +631,3 @@ Generated by [AVA](https://ava.li). Error location␊ In "onInit" event in local plugin "/file/path"␊ ` - -## utils.status.show() argument should be an object - -> Snapshot 2 - - `␊ - ┌─────────────────────────────┐␊ - │ Netlify Build │␊ - └─────────────────────────────┘␊ - ␊ - > Version␊ - @netlify/build 1.0.0␊ - ␊ - > Flags␊ - repositoryRoot: /file/path␊ - ␊ - ┌─────────────────────────────┐␊ - │ Configuration error │␊ - └─────────────────────────────┘␊ - ␊ - Error message␊ - Option 'repositoryRoot' points to a non-existing directory: /file/path␊ - ` diff --git a/packages/build/tests/plugins/status/snapshots/tests.js.snap b/packages/build/tests/plugins/status/snapshots/tests.js.snap index f578ddf5a6..9706edc388 100644 Binary files a/packages/build/tests/plugins/status/snapshots/tests.js.snap and b/packages/build/tests/plugins/status/snapshots/tests.js.snap differ diff --git a/packages/build/tests/plugins/status/tests.js b/packages/build/tests/plugins/status/tests.js index ed9f6f9d8f..6a672f68a9 100644 --- a/packages/build/tests/plugins/status/tests.js +++ b/packages/build/tests/plugins/status/tests.js @@ -26,6 +26,10 @@ test('utils.status.show() requires a summary', async t => { await runUtilsStatusShow(t, { title: 'title', text: 'text' }) }) +test('utils.status.show() allow other fields to be optional', async t => { + await runUtilsStatusShow(t, { summary: 'summary' }) +}) + test('utils.status.show() title should be a string', async t => { await runUtilsStatusShow(t, { title: true, summary: 'summary', text: 'text' }) })