This commit is contained in:
Benjamin Pasero
2017-12-20 16:57:40 +01:00
parent 6bac0e2235
commit 549cda29da
5 changed files with 13 additions and 13 deletions

View File

@@ -57,8 +57,8 @@ export async function main(argv: string[]): TPromise<any> {
return mainCli.then(cli => cli.main(args));
}
// Write Elevated
else if (args['sudo-write']) {
// Write File
else if (args['file-write']) {
const source = args._[0];
const target = args._[1];
@@ -69,7 +69,7 @@ export async function main(argv: string[]): TPromise<any> {
!fs.existsSync(source) || !fs.statSync(source).isFile() || // make sure source exists as file
!fs.existsSync(target) || !fs.statSync(target).isFile() // make sure target exists as file
) {
return TPromise.wrapError(new Error('Using --sudo-write with invalid arguments.'));
return TPromise.wrapError(new Error('Using --file-write with invalid arguments.'));
}
try {
@@ -77,7 +77,7 @@ export async function main(argv: string[]): TPromise<any> {
// Check for readonly status and chmod if so if we are told so
let targetMode: number;
let restoreMode = false;
if (!!args['sudo-chmod']) {
if (!!args['file-chmod']) {
targetMode = fs.statSync(target).mode;
if (!(targetMode & 128) /* readonly */) {
fs.chmodSync(target, targetMode | 128);
@@ -106,7 +106,7 @@ export async function main(argv: string[]): TPromise<any> {
fs.chmodSync(target, targetMode);
}
} catch (error) {
return TPromise.wrapError(new Error(`Using --sudo-write resulted in an error: ${error}`));
return TPromise.wrapError(new Error(`Using --file-write resulted in an error: ${error}`));
}
return TPromise.as(null);