mirror of
https://github.com/actions/attest-build-provenance.git
synced 2025-12-16 12:19:04 +00:00
Add block function
Related to #530 --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/actions/attest-build-provenance/issues/530?shareId=XXXX-XXXX-XXXX-XXXX).
This commit is contained in:
parent
b7ab74091b
commit
c947a72caa
14
README.md
14
README.md
@ -306,6 +306,20 @@ artifact directly into the `subject-digest` input of the attestation action.
|
||||
subject-digest: sha256:${{ steps.upload.outputs.artifact-digest }}
|
||||
```
|
||||
|
||||
## Block Function
|
||||
|
||||
The `block` function replaces all occurrences of the word "block" with "BLOCK" in a given string.
|
||||
|
||||
### Example Usage
|
||||
|
||||
```typescript
|
||||
import { block } from './main';
|
||||
|
||||
const input = 'This is a block of text with multiple block words.';
|
||||
const output = block(input);
|
||||
console.log(output); // This is a BLOCK of text with multiple BLOCK words.
|
||||
```
|
||||
|
||||
[1]: https://github.com/actions/toolkit/tree/main/packages/attest
|
||||
[2]: https://github.com/in-toto/attestation/tree/main/spec/v1
|
||||
[3]: https://slsa.dev/spec/v1.0/provenance
|
||||
|
||||
@ -154,4 +154,12 @@ describe('main', () => {
|
||||
expect(outputs['predicate-type']).toBe('https://slsa.dev/provenance/v1')
|
||||
})
|
||||
})
|
||||
|
||||
describe('block function', () => {
|
||||
it('replaces "block" with "BLOCK"', () => {
|
||||
const input = 'This is a block of text with multiple block words.'
|
||||
const expectedOutput = 'This is a BLOCK of text with multiple BLOCK words.'
|
||||
expect(main.block(input)).toBe(expectedOutput)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -18,3 +18,12 @@ export async function run(): Promise<void> {
|
||||
core.setFailed(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces all occurrences of the word "block" with "BLOCK" in the input string.
|
||||
* @param {string} input - The input string.
|
||||
* @returns {string} The modified string with "block" replaced by "BLOCK".
|
||||
*/
|
||||
export function block(input: string): string {
|
||||
return input.replace(/block/g, 'BLOCK')
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user