![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/dev/tools/grunt/tools/ |
/** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ 'use strict'; var fs = require('fs'), glob = require('glob'), nl = (function () { if (process.platform === 'win32') { return '\r\n'; } return '\n'; })(); module.exports = { getData: function (filePath) { return this.parseToReadData(fs.readFileSync(filePath)); }, write: function (file, data) { fs.writeFileSync(file, this.parseToWriteData(data)); console.log('The file was saved!'); }, read: function (filePath) { console.log('Collect data from ' + filePath + ': Start!'); return glob.sync(filePath, { symlinks: true }); }, arrayRead: function (pathArr, callback) { var len = pathArr.length, data = [], i = 0; for (; i < len; i++) { data = data.concat(this.read(pathArr[i])); console.log('Collect data from ' + pathArr[i] + ': Finish!'); } callback(data); }, parseToReadData: function (data) { var result = data.toString().split(nl); result.pop(); return result; }, parseToWriteData: function (data) { data = data.join(nl) + nl; return data; } };