-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd206be
commit 1e706e6
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
|
||
let log = require('../../util/logger')('install/naked') | ||
let rimraf = require('../../promised/rimraf') | ||
|
||
let fs = require('fs') | ||
let path = require('path') | ||
|
||
function cp (source, target) { | ||
return new Promise(function (resolve, reject) { | ||
var rd = fs.createReadStream(source) | ||
rd.on('error', reject) | ||
var wr = fs.createWriteStream(target) | ||
wr.on('error', reject) | ||
wr.on('finish', resolve) | ||
rd.pipe(wr) | ||
}) | ||
} | ||
|
||
let self = { | ||
install: async function (opts) { | ||
let archive_path = opts.archive_path | ||
let dest_path = opts.dest_path | ||
|
||
let dest_file_path = path.join(dest_path, path.basename(archive_path)) | ||
log(opts, `copying ${archive_path} to ${dest_file_path}`) | ||
|
||
await cp(archive_path, dest_file_path) | ||
}, | ||
|
||
uninstall: async function (opts) { | ||
let dest_path = opts.dest_path | ||
|
||
log(opts, `nuking ${dest_path}`) | ||
|
||
await rimraf(dest_path, { | ||
disableGlob: true // rm -rf + globs sound like the kind of evening I don't like | ||
}) | ||
} | ||
} | ||
|
||
module.exports = self |