This app provides monitoring and information features for the common freifunk user and the technical stuff of a freifunk community.
Code base is taken from a TUM Practical Course project and added here to see if Freifunk Altdorf can use it.
https://www.freifunk-altdorf.de
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.5 KiB
50 lines
1.5 KiB
var fs = require('graceful-fs') |
|
var path = require('path') |
|
var ncp = require('./ncp') |
|
var mkdir = require('../mkdirs') |
|
|
|
function copy (src, dest, options, callback) { |
|
if (typeof options === 'function' && !callback) { |
|
callback = options |
|
options = {} |
|
} else if (typeof options === 'function' || options instanceof RegExp) { |
|
options = {filter: options} |
|
} |
|
callback = callback || function () {} |
|
options = options || {} |
|
|
|
// Warn about using preserveTimestamps on 32-bit node: |
|
if (options.preserveTimestamps && process.arch === 'ia32') { |
|
console.warn('fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n' + |
|
'see https://github.com/jprichardson/node-fs-extra/issues/269') |
|
} |
|
|
|
// don't allow src and dest to be the same |
|
var basePath = process.cwd() |
|
var currentPath = path.resolve(basePath, src) |
|
var targetPath = path.resolve(basePath, dest) |
|
if (currentPath === targetPath) return callback(new Error('Source and destination must not be the same.')) |
|
|
|
fs.lstat(src, function (err, stats) { |
|
if (err) return callback(err) |
|
|
|
var dir = null |
|
if (stats.isDirectory()) { |
|
var parts = dest.split(path.sep) |
|
parts.pop() |
|
dir = parts.join(path.sep) |
|
} else { |
|
dir = path.dirname(dest) |
|
} |
|
|
|
fs.exists(dir, function (dirExists) { |
|
if (dirExists) return ncp(src, dest, options, callback) |
|
mkdir.mkdirs(dir, function (err) { |
|
if (err) return callback(err) |
|
ncp(src, dest, options, callback) |
|
}) |
|
}) |
|
}) |
|
} |
|
|
|
module.exports = copy
|
|
|