-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(build): create custom transform to remove line break characters fr…
…om comments created by ts descriptions
- Loading branch information
Showing
2 changed files
with
27 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { DesignToken } from 'style-dictionary/types'; | ||
|
||
/** | ||
* Helper: Maps the token description to a style dictionary comment attribute - this will be picked up by some Style Dictionary | ||
* formats and automatically output as code comments | ||
*/ | ||
export function mapDescriptionToComment(token: DesignToken): DesignToken { | ||
// intentional mutation of the original object | ||
const _t = token; | ||
// Replace carriage returns with just newlines | ||
_t.comment = _t['description'].replace(/\r?\n|\r/g, ' '); | ||
return _t; | ||
} |