deno.land / x / lodash@4.17.19 / lib / common / file.js

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
'use strict';
const _ = require('lodash');const fs = require('fs-extra');const glob = require('glob');const path = require('path');
const minify = require('../common/minify.js');
/*----------------------------------------------------------------------------*/
/** * Creates a [fs.copy](https://github.com/jprichardson/node-fs-extra#copy) * function with `srcPath` and `destPath` partially applied. * * @memberOf file * @param {string} srcPath The path of the file to copy. * @param {string} destPath The path to copy the file to. * @returns {Function} Returns the partially applied function. */function copy(srcPath, destPath) { return _.partial(fs.copy, srcPath, destPath);}
/** * Creates an object of base name and compiled template pairs that match `pattern`. * * @memberOf file * @param {string} pattern The glob pattern to be match. * @returns {Object} Returns the object of compiled templates. */function globTemplate(pattern) { return _.transform(glob.sync(pattern), (result, filePath) => { const key = path.basename(filePath, path.extname(filePath)); result[key] = _.template(fs.readFileSync(filePath, 'utf8')); }, {});}
/** * Creates a `minify` function with `srcPath` and `destPath` partially applied. * * @memberOf file * @param {string} srcPath The path of the file to minify. * @param {string} destPath The path to write the file to. * @returns {Function} Returns the partially applied function. */function min(srcPath, destPath) { return _.partial(minify, srcPath, destPath);}
/** * Creates a [fs.writeFile](https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback) * function with `filePath` and `data` partially applied. * * @memberOf file * @param {string} destPath The path to write the file to. * @param {string} data The data to write to the file. * @returns {Function} Returns the partially applied function. */function write(destPath, data) { return _.partial(fs.writeFile, destPath, data);}
/*----------------------------------------------------------------------------*/
module.exports = { copy, globTemplate, min, write};
lodash

Version Info

Tagged at
3 years ago

External Dependencies

No external dependencies 🎉