Skip to content

daemonchen/plover-assets-util

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

plover-assets-util

NPM version build status Test coverage

资源编译相关工具类

Installing

npm install --save plover-assets-util

List

template

字符串模版格式化。

参数
name description
pattern 字符串模版,以{}格式的模版
data 填充模版的数据

e.g.

const util = require('plover-assets-util');

const data = {
  name: 'common',
  path: 'js/bridge.js'
};

let url = '/g/{name}/{path}';

url = util.template(url, data);  // "/g/common/js/bridge.js"

scanDir

根据一定规则扫描目录文件。

参数
name description
dir 待扫描的目录
options 可选项

e.g.

const pathUtil = require('path');
const util = require('plover-assets-util');

const dir = pathUtil.join(__dirname, 'common');
const paths = util.scanDir(dir, {
  match: [''],
  ignore: [''],
  relative: ''
});

hashDir

获取一个目录的hash值。

参数
name description
dir 待计算hash值的目录
options 可选项

e.g.

const pathUtil = require('path');
const util = require('plover-assets-util');

const dir = pathUtil.join(__dirname, 'common');
const hashcode = util.hashDir(dir, {
  salt: ''
});

About

资源编译相关工具类

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%