0.1.0 • Published 2 years ago

@syyfe/syy-utils-node v0.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

商业云 node 工具库

安装

npm i @syyfe/syy-utils-node -D

Log 常用的方法

interface ILog {
    /** chalk 对象 https://www.npmjs.com/package/chalk */
    chalk: any;

    log(msg: string, tag?: string): void;

    info(msg: string, tag?: string): void;

    start(msg: string, tag?: string): void;

    done(msg: string, tag?: string): void;

    warn(msg: string, tag?: string): void;

    error(msg: string | Error, tag?: string): void;
}

日期格式

/**
 * 日期格式化
 * fmt 默认  = "yyyy-MM-dd"
 */
export type IFormatDate = (date: Date, fmt?: string) => string;

实例

const { Log, formatDate } = require("@syyfe/syy-utils-node");

console.log(formatDate(new Date()));

Log.start("=====start message");
Log.info("=====info message");
Log.done("=====done message");
Log.error("=====error message");
Log.warn("=====warn message");
Log.log("log message");
console.log(Log.chalk.bgBlue.black(" START "));
console.log(Log.chalk.blue("1231232"));

fs

const { fs } = require("../lib");

const cwd = `/Users/zhendao/Desktop/Code/demo/monaco-editor`;

// 删除文件夹
fs.removeDir(cwd + "/node_modules");

npm

const { npm } = require("../lib");

const cwd = `/Users/zhendao/Desktop/Code/demo/monaco-editor`;
// 安装
npm.install(cwd);
// 删除
npm.remove(cwd);

npm.removePackageLock(cwd);

examples

效果

avatar