Server IP : 127.0.0.2 / Your IP : 3.144.200.28 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/local/lib/node_modules/less/test/ |
Upload File : |
/* jshint latedef: nofunc */ // This is used to copy a folder (the test/less/* files & sub-folders), adding a BOM to the start of each LESS and CSS file. // This is a based on the copySync method from fs-extra (https://github.com/jprichardson/node-fs-extra/). module.exports = function() { var path = require('path'), fs = require('fs'); var BUF_LENGTH = 64 * 1024; var _buff = new Buffer(BUF_LENGTH); function copyFolderWithBom(src, dest) { var stats = fs.lstatSync(src); var destFolder = path.dirname(dest); var destFolderExists = fs.existsSync(destFolder); var performCopy = false; if (stats.isFile()) { if (!destFolderExists) { fs.mkdirSync(destFolder); } if (src.match(/\.(css|less)$/)) { copyFileAddingBomSync(src, dest); } else { copyFileSync(src, dest); } } else if (stats.isDirectory()) { if (!fs.existsSync(destFolder)) { fs.mkdirSync(destFolder); } if (!fs.existsSync(dest)) { fs.mkdirSync(dest); } fs.readdirSync(src).forEach(function(d) { if (d !== 'bom') { copyFolderWithBom(path.join(src, d), path.join(dest, d)); } }); } } function copyFileAddingBomSync(srcFile, destFile) { var contents = fs.readFileSync(srcFile, { encoding: 'utf8' }); if (!contents.length || contents.charCodeAt(0) !== 0xFEFF) { contents = '\ufeff' + contents; } fs.writeFileSync(destFile, contents, { encoding: 'utf8' }); } function copyFileSync(srcFile, destFile) { var fdr = fs.openSync(srcFile, 'r'); var stat = fs.fstatSync(fdr); var fdw = fs.openSync(destFile, 'w', stat.mode); var bytesRead = 1; var pos = 0; while (bytesRead > 0) { bytesRead = fs.readSync(fdr, _buff, 0, BUF_LENGTH, pos) fs.writeSync(fdw, _buff, 0, bytesRead); pos += bytesRead; } fs.closeSync(fdr); fs.closeSync(fdw); } return { copyFolderWithBom: copyFolderWithBom }; };