Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #755 from misterdev/feature/opencollective-postins…
…tall enh(Add open collective prompt)
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 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,33 @@ | ||
const chalk = require("chalk"); | ||
|
||
// Only show emoji on OSx (Windows shell doesn't like them that much ¯\_(ツ)_/¯ ) | ||
function emoji(emoji) { | ||
if (process.stdout.isTTY && process.platform === "darwin") { | ||
return emoji; | ||
} else { | ||
return ""; | ||
} | ||
} | ||
|
||
function print(str = "", color = "dim") { | ||
const terminalCols = 80; | ||
// eslint-disable-next-line no-control-regex | ||
const ansiEscapeSeq = /\u001b\[[0-9]{1,2}m/g; | ||
const strLength = str.replace(ansiEscapeSeq, "").length; | ||
const leftPaddingLength = Math.floor((terminalCols - strLength) / 2); | ||
const leftPadding = " ".repeat(leftPaddingLength); | ||
str = chalk[color](str); | ||
console.log(leftPadding, str); | ||
} | ||
|
||
function printBadge() { | ||
console.log("\n"); | ||
print(`${chalk.bold("Thanks for using")} ${chalk.bold.blue("Webpack!")}`); | ||
print(`Please consider donating to our ${chalk.bold.blue("Open Collective")}`); | ||
print("to help us maintain this package."); | ||
console.log("\n\n"); | ||
print(`${emoji("👉")} ${chalk.bold.yellow(" Donate:")} ${chalk.reset.underline.yellow("https://opencollective.com/webpack/donate")}`); | ||
console.log("\n"); | ||
} | ||
|
||
printBadge(); |
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