README
🐸 @omni-door/tpl-utils
The Utils for @omni-door/cli and other templates project.
Install
Clone the repo:
git clone git@github.com:omni-door/tpl-utils.git
Install with npm:
npm install @omni-door/tpl-utils
Install with Yarn:
yarn add @omni-door/tpl-utils
Methods
exec
import { exec } from '@omni-door/tpl-utils'; exec( ['npm test', 'ls && pwd', 'npm run build'], () => console.info('成功!'), () => console.error('失败!') );
logPrefix
import { logPrefix } from '@omni-door/tpl-utils'; logPrefix(); // 😊 [OMNI-DOOR]:
setLogo
import { setLogo } from '@omni-door/tpl-utils'; setLogo('❤️️️️ ');
setBrand
import { setBrand } from '@omni-door/tpl-utils'; setBrand('ODYSSEY');
getLogo
import { getLogo } from '@omni-door/tpl-utils'; getLogo(); // ❤️️
getBrand
import { getBrand } from '@omni-door/tpl-utils'; getBrand(); // ODYSSEY
logDetail
import { logDetail } from '@omni-door/tpl-utils'; logDetail('this is a message!'); // ❤️️ [ODYSSEY]: this is a message! (gray)
logEmph
import { logEmph } from '@omni-door/tpl-utils'; logEmph('this is a message!'); // ❤️️ [ODYSSEY]: this is a message! (cyan)
logErr
import { logErr } from '@omni-door/tpl-utils'; logErr('this is a message!'); // ❤️️ [ODYSSEY]: this is a message! (red)
logInfo
import { logInfo } from '@omni-door/tpl-utils'; logInfo('this is a message!'); // ❤️️ [ODYSSEY]: this is a message! (white)
logSuc
import { logSuc } from '@omni-door/tpl-utils'; logSuc('this is a message!'); // ❤️️ [ODYSSEY]: this is a message! (green)
logWarn
import { logWarn } from '@omni-door/tpl-utils'; logWarn('this is a message!'); // ❤️️ [ODYSSEY]: this is a message! (yellow)
underline
import { underline } from '@omni-door/tpl-utils'; logWarn(underline('this is a message!')); // ❤️️ [ODYSSEY]: this is a message! (has underline)
italic
import { italic } from '@omni-door/tpl-utils'; logDetail(italic('this is a message!')); // ❤️️ [ODYSSEY]: this is a message! (italic font)
node_version
node -v # v10.13.0
import { node_version } from '@omni-door/tpl-utils'; // pass (async function () { // require node version >= 10 await node_version('10'); })() // can't through the check and will be exit with warn log (async function () { // require node version >= 10.14 await node_version('10.14'); })() // can't through the check and will be exit with warn log (async function () { // require node version >= 10.13.1 await node_version('10.13.1'); })()
output_file
import { output_file } from '@omni-door/tpl-utils'; output_file({ file_path: file_path('src/test.txt'), file_content: 'I am a test content!' });
getDependency
import { getDependency } from '@omni-door/tpl-utils'; const dependency = getDependency('latest', { 'core-js': '3.6.4', 'react': '16.12.0', 'react-dom': '16.12.0', 'regenerator-runtime': '0.13.3' }); const dependency_stable = getDependency('stable', { 'core-js': '3.6.4', 'react': '16.12.0', 'react-dom': '16.12.0', 'regenerator-runtime': '0.13.3' }); dependency('react'); // 'react@latest' dependency_stable('react'); // 'react@16.12.0'
arr2str
import { arr2str } from '@omni-door/tpl-utils'; arr2str([1, 2, 3]); // "1 2 3"
intersection
import { intersection } from '@omni-door/tpl-utils'; depArr = [ ...intersection(depArr, depArr.filter(v => v !== 1)) ]
spinner
import { spinner } from '@omni-door/tpl-utils'; spinner.state('start', 'begin!'); spinner.text('new text'); spinner.color('red'); spinner.prefix('dot8'); spinner.state('succeed', 'succeed!');