Skip to content

Commit

Permalink
Don't do dangerous operations without --force
Browse files Browse the repository at this point in the history
  • Loading branch information
rictic committed Aug 22, 2017
1 parent b194c81 commit 9770fac
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,17 @@ const optionDefinitions: commandLineArgs.OptionDefinition[] = [
{
name: 'clear',
type: Boolean,
defaultValue: false,
description: 'Clear the out directory (if one exists) before running.',
},
{
name: 'force',
type: Boolean,
defaultValue: false,
description:
`If given, may overwrite or delete files when converting the given ` +
`input directory.`,
},
];

interface Options {
Expand All @@ -140,6 +149,7 @@ interface Options {
'workspace-dir'?: string;
'github-token'?: string;
'prerelease-version'?: string;
force: boolean;
}

export async function run() {
Expand Down Expand Up @@ -196,6 +206,17 @@ installation.
return;
}

// Ok, we're updating a package in a directory not under our control.
// We need to be sure it's safe. In a future PR let's check with git, but
// for now, we'll ask the user to pass in a --force flag.
if (!options.force) {
console.error(
`When running modulizer on an existing directory, ` +
`be sure that all changes are checked into source control. ` +
`Run with --force once you've verified.`);
process.exit(1);
}

// TODO: each file is not always needed, refactor to optimize loading
let inBowerJson: {name: string, version: string, main: any}|undefined;
let inPackageJson: {name: string, version: string}|undefined;
Expand Down

0 comments on commit 9770fac

Please sign in to comment.