feat: docker compose maybe
This commit is contained in:
47
node_modules/sander/src/extraMethods/copyFile.js
generated
vendored
Normal file
47
node_modules/sander/src/extraMethods/copyFile.js
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
import * as fs from 'graceful-fs';
|
||||
import { dirname } from 'path';
|
||||
import mkdirp from 'mkdirp';
|
||||
import resolvePathAndOptions from '../utils/resolvePathAndOptions';
|
||||
|
||||
export function copyFile () {
|
||||
const { resolvedPath: src, options: readOptions } = resolvePathAndOptions( arguments );
|
||||
|
||||
return {
|
||||
to () {
|
||||
const { resolvedPath: dest, options: writeOptions } = resolvePathAndOptions( arguments );
|
||||
|
||||
return new Promise( ( fulfil, reject ) => {
|
||||
mkdirp( dirname( dest ), err => {
|
||||
if ( err ) {
|
||||
reject( err );
|
||||
} else {
|
||||
const readStream = fs.createReadStream( src, readOptions );
|
||||
const writeStream = fs.createWriteStream( dest, writeOptions );
|
||||
|
||||
readStream.on( 'error', reject );
|
||||
writeStream.on( 'error', reject );
|
||||
|
||||
writeStream.on( 'close', fulfil );
|
||||
|
||||
readStream.pipe( writeStream );
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function copyFileSync () {
|
||||
const { resolvedPath: src, options: readOptions } = resolvePathAndOptions( arguments );
|
||||
|
||||
return {
|
||||
to () {
|
||||
const { resolvedPath: dest, options: writeOptions } = resolvePathAndOptions( arguments );
|
||||
|
||||
const data = fs.readFileSync( src, readOptions );
|
||||
|
||||
mkdirp.sync( dirname( dest ) );
|
||||
fs.writeFileSync( dest, data, writeOptions );
|
||||
}
|
||||
};
|
||||
}
|
99
node_modules/sander/src/extraMethods/copydir.js
generated
vendored
Normal file
99
node_modules/sander/src/extraMethods/copydir.js
generated
vendored
Normal file
@ -0,0 +1,99 @@
|
||||
import { sep } from 'path';
|
||||
import * as fs from 'graceful-fs';
|
||||
import mkdirp from 'mkdirp';
|
||||
import resolvePathAndOptions from '../utils/resolvePathAndOptions';
|
||||
|
||||
export function copydir () {
|
||||
const { resolvedPath: src, options: readOptions } = resolvePathAndOptions( arguments );
|
||||
|
||||
return {
|
||||
to () {
|
||||
const { resolvedPath: dest, options: writeOptions } = resolvePathAndOptions( arguments );
|
||||
|
||||
function copydir ( src, dest, cb ) {
|
||||
mkdirp( dest, err => {
|
||||
if ( err ) return cb( err );
|
||||
|
||||
fs.readdir( src, ( err, files ) => {
|
||||
if ( err ) return cb( err );
|
||||
|
||||
let remaining = files.length;
|
||||
|
||||
if ( !remaining ) return cb();
|
||||
|
||||
function check ( err ) {
|
||||
if ( err ) {
|
||||
return cb( err );
|
||||
}
|
||||
|
||||
if ( !--remaining ) {
|
||||
cb();
|
||||
}
|
||||
}
|
||||
|
||||
files.forEach( function ( filename ) {
|
||||
const srcpath = src + sep + filename;
|
||||
const destpath = dest + sep + filename;
|
||||
|
||||
fs.stat( srcpath, ( err, stats ) => {
|
||||
var readStream, writeStream;
|
||||
|
||||
if ( stats.isDirectory() ) {
|
||||
return copydir( srcpath, destpath, check );
|
||||
}
|
||||
|
||||
readStream = fs.createReadStream( srcpath, readOptions );
|
||||
writeStream = fs.createWriteStream( destpath, writeOptions );
|
||||
|
||||
readStream.on( 'error', cb );
|
||||
writeStream.on( 'error', cb );
|
||||
|
||||
writeStream.on( 'close', check );
|
||||
|
||||
readStream.pipe( writeStream );
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return new Promise( ( fulfil, reject ) => {
|
||||
copydir( src, dest, err => {
|
||||
if ( err ) {
|
||||
reject( err );
|
||||
} else {
|
||||
fulfil();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function copydirSync () {
|
||||
const { resolvedPath: src, options: readOptions } = resolvePathAndOptions( arguments );
|
||||
|
||||
return {
|
||||
to () {
|
||||
const { resolvedPath: dest, options: writeOptions } = resolvePathAndOptions( arguments );
|
||||
|
||||
function copydir ( src, dest ) {
|
||||
mkdirp.sync( dest );
|
||||
|
||||
fs.readdirSync( src ).forEach( filename => {
|
||||
const srcpath = src + sep + filename;
|
||||
const destpath = dest + sep + filename;
|
||||
|
||||
if ( fs.statSync( srcpath ).isDirectory() ) {
|
||||
return copydir( srcpath, destpath );
|
||||
}
|
||||
|
||||
const data = fs.readFileSync( srcpath, readOptions );
|
||||
fs.writeFileSync( destpath, data, writeOptions );
|
||||
});
|
||||
}
|
||||
|
||||
copydir( src, dest );
|
||||
}
|
||||
};
|
||||
}
|
70
node_modules/sander/src/extraMethods/lsr.js
generated
vendored
Normal file
70
node_modules/sander/src/extraMethods/lsr.js
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
import * as fs from 'fs';
|
||||
import { resolve, sep } from 'path';
|
||||
import resolvePath from '../utils/resolvePath';
|
||||
|
||||
function walk ( dir, callback ) {
|
||||
let results = [];
|
||||
|
||||
fs.readdir( dir, ( err, files ) => {
|
||||
if ( err ) return callback( err );
|
||||
|
||||
let pending = files.length;
|
||||
if ( !pending ) return callback( null, results );
|
||||
|
||||
files.forEach( file => {
|
||||
file = resolve( dir, file );
|
||||
|
||||
fs.stat( file, ( err, stats ) => {
|
||||
if ( stats && stats.isDirectory() ) {
|
||||
walk( file, ( err, res ) => {
|
||||
results = results.concat( res );
|
||||
if ( !--pending ) callback( null, results );
|
||||
});
|
||||
} else {
|
||||
results.push( file );
|
||||
if ( !--pending ) callback( null, results );
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export function lsr () {
|
||||
const basedir = resolvePath( arguments );
|
||||
|
||||
return new Promise( ( fulfil, reject ) => {
|
||||
walk( basedir, function ( err, result ) {
|
||||
if ( err ) return reject( err );
|
||||
|
||||
// files should be relative to basedir
|
||||
const index = basedir.length + 1;
|
||||
let i = result.length;
|
||||
while ( i-- ) {
|
||||
result[i] = result[i].substring( index );
|
||||
}
|
||||
|
||||
fulfil( result );
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function lsrSync () {
|
||||
const basedir = resolvePath( arguments );
|
||||
|
||||
let result = [];
|
||||
|
||||
function processdir ( dir ) {
|
||||
fs.readdirSync( dir ).forEach( file => {
|
||||
const filepath = dir + sep + file;
|
||||
|
||||
if ( fs.statSync( filepath ).isDirectory() ) {
|
||||
processdir( filepath );
|
||||
} else {
|
||||
result.push( filepath.replace( basedir + sep, '' ) );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
processdir( basedir );
|
||||
return result;
|
||||
}
|
20
node_modules/sander/src/extraMethods/rimraf.js
generated
vendored
Normal file
20
node_modules/sander/src/extraMethods/rimraf.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
import _rimraf from 'rimraf';
|
||||
import resolvePath from '../utils/resolvePath';
|
||||
|
||||
export function rimraf () {
|
||||
const target = resolvePath( arguments );
|
||||
|
||||
return new Promise( ( fulfil, reject ) => {
|
||||
_rimraf( target, err => {
|
||||
if ( err ) {
|
||||
reject( err );
|
||||
} else {
|
||||
fulfil();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function rimrafSync () {
|
||||
_rimraf.sync( resolvePath( arguments ) );
|
||||
}
|
40
node_modules/sander/src/extraMethods/symlinkOrCopy.js
generated
vendored
Normal file
40
node_modules/sander/src/extraMethods/symlinkOrCopy.js
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
import { stat, statSync } from '../sander';
|
||||
import { copydir, copydirSync } from './copydir';
|
||||
import { copyFile, copyFileSync } from './copyFile';
|
||||
import { symlink, symlinkSync } from '../specialMethods/symlink';
|
||||
import resolvePathAndOptions from '../utils/resolvePathAndOptions';
|
||||
|
||||
const isWindows = process.platform === 'win32';
|
||||
|
||||
export function symlinkOrCopy () {
|
||||
if ( isWindows ) {
|
||||
const { resolvedPath: src, options: readOptions } = resolvePathAndOptions( arguments );
|
||||
|
||||
let copyDirOrFileTo = stat( src )
|
||||
.then( stats => {
|
||||
return ( stats.isDirectory() ? copydir : copyFile )
|
||||
.apply( null, arguments )
|
||||
.to;
|
||||
});
|
||||
|
||||
return {
|
||||
to () {
|
||||
return copyDirOrFileTo
|
||||
.then(fn => {
|
||||
return fn.apply(null, arguments);
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return symlink.apply( null, arguments );
|
||||
}
|
||||
|
||||
export function symlinkOrCopySync () {
|
||||
if ( isWindows ) {
|
||||
const { resolvedPath: src, options: readOptions } = resolvePathAndOptions( arguments );
|
||||
return ( statSync( src ).isDirectory() ? copydirSync : copyFileSync ).apply( null, arguments );
|
||||
}
|
||||
|
||||
return symlinkSync.apply( null, arguments );
|
||||
}
|
Reference in New Issue
Block a user