Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
var path = require('path');
var fsExtra = require('fs-extra');
var pify = require('pify');
var Promise = require('pinkie-promise');
var uuid = require('uuid');
var xdgTrashdir = require('xdg-trashdir');
var fs = pify.all(fsExtra, Promise);
function trash(src) {
return xdgTrashdir(src).then(function (dir) {
var name = uuid.v4();
var dest = path.join(dir, 'files', name);
var info = path.join(dir, 'info', name + '.trashinfo');
var msg = [
'[Trash Info]',
'Path=' + src.replace(/\s/g, '%20'),
'DeletionDate=' + new Date().toISOString()
].join('\n');
return Promise.all([
fs.move(src, dest, {mkdirp: true}).then(function () {
return dest;
}),