Skip to content

Commit

Permalink
chore: update indent size
Browse files Browse the repository at this point in the history
  • Loading branch information
justinlettau committed Mar 10, 2018
1 parent 3aa838b commit 807b939
Show file tree
Hide file tree
Showing 18 changed files with 943 additions and 942 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ node_js:
- "node"

before_install:
- npm install
- npm install

script:
- npm run lint
- npm run build
- npm run lint
- npm run build
32 changes: 16 additions & 16 deletions src/commands/cat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ import * as util from '../common/utility';
* Concatenate all SQL files into a single file.
*/
export function cat(): void {
const start: [number, number] = process.hrtime();
const config: Config = util.getConfig();
let output: string = '';
const start: [number, number] = process.hrtime();
const config: Config = util.getConfig();
let output: string = '';

// order is important
const files: string[] = util.getFilesOrdered(config);
// order is important
const files: string[] = util.getFilesOrdered(config);

for (const file of files) {
const content: string = fs.readFileSync(file).toString();
const end: string = content.substr(-2).toLowerCase();
for (const file of files) {
const content: string = fs.readFileSync(file).toString();
const end: string = content.substr(-2).toLowerCase();

output += content;
output += EOL;
output += (end !== 'go' ? 'go' : '');
output += EOL + EOL;
}
output += content;
output += EOL;
output += (end !== 'go' ? 'go' : '');
output += EOL + EOL;
}

fs.outputFileSync(`${config.output.root}/cat.sql`, output);
fs.outputFileSync(`${config.output.root}/cat.sql`, output);

const time: [number, number] = process.hrtime(start);
console.log(chalk.green(`Finished after ${time[0]}s!`));
const time: [number, number] = process.hrtime(start);
console.log(chalk.green(`Finished after ${time[0]}s!`));
}
34 changes: 17 additions & 17 deletions src/commands/conns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ import * as util from '../common/utility';
* List all available connections.
*/
export function conns(): void {
const config: Config = util.getConfig();
const connections: Connection[] = util.getConns(config);
const placeholder: string = 'n/a';
const config: Config = util.getConfig();
const connections: Connection[] = util.getConns(config);
const placeholder: string = 'n/a';

const table: Table = new Table({
head: ['Name', 'Server', 'Port', 'Database', 'User', 'Password']
});
const table: Table = new Table({
head: ['Name', 'Server', 'Port', 'Database', 'User', 'Password']
});

for (const conn of connections) {
table.push([
conn.name || placeholder,
conn.server || placeholder,
conn.port || placeholder,
conn.database || placeholder,
conn.user || placeholder,
conn.password || placeholder
]);
}
for (const conn of connections) {
table.push([
conn.name || placeholder,
conn.server || placeholder,
conn.port || placeholder,
conn.database || placeholder,
conn.user || placeholder,
conn.password || placeholder
]);
}

console.log(table.toString());
console.log(table.toString());
}
150 changes: 75 additions & 75 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import * as util from '../common/utility';
* CLI arguments for `init` command.
*/
interface InitOptions {
webconfig?: string;
force?: boolean;
skip?: boolean;
webconfig?: string;
force?: boolean;
skip?: boolean;
}

/**
Expand All @@ -19,81 +19,81 @@ interface InitOptions {
* @param options CommanderJS options.
*/
export function init(options: InitOptions): void {
const webConfigFile: string = options.webconfig || util.webConfigFile;
const webConfigConns: Connection[] = util.getWebConfigConns(webConfigFile);
const conn: Connection = new Connection();
const webConfigFile: string = options.webconfig || util.webConfigFile;
const webConfigConns: Connection[] = util.getWebConfigConns(webConfigFile);
const conn: Connection = new Connection();

if (webConfigConns) {
// use options from web config
Object.assign(conn, webConfigConns[0]);
}
if (webConfigConns) {
// use options from web config
Object.assign(conn, webConfigConns[0]);
}

if (fs.existsSync(util.configFile) && !options.force) {
// don't overwrite existing config file
return console.error('Config file already exists!');
}
if (fs.existsSync(util.configFile) && !options.force) {
// don't overwrite existing config file
return console.error('Config file already exists!');
}

if (options.skip) {
// skip prompts and create with defaults
util.setConfig({ connections: options.webconfig || [conn] });
return;
}
if (options.skip) {
// skip prompts and create with defaults
util.setConfig({ connections: options.webconfig || [conn] });
return;
}

const questions: inquirer.Questions = [
{
name: 'path',
message: 'Use connections from Web.config file?',
type: 'confirm',
when: (): boolean => !!webConfigConns
}, {
name: 'server',
message: 'Server URL.',
default: (conn.server || undefined),
when: (answers): boolean => (!webConfigConns || !answers.path)
}, {
name: 'port',
message: 'Server port.',
default: (conn.port || undefined),
when: (answers): boolean => (!webConfigConns || !answers.path)
}, {
name: 'database',
message: 'Database name.',
default: (conn.database || undefined),
when: (answers): boolean => (!webConfigConns || !answers.path)
}, {
name: 'user',
message: 'Login username.',
default: (conn.user || undefined),
when: (answers): boolean => (!webConfigConns || !answers.path)
}, {
name: 'password',
message: 'Login password.',
default: (conn.password || undefined),
when: (answers): boolean => (!webConfigConns || !answers.path)
}, {
name: 'name',
message: 'Connection name.',
default: 'dev',
when: (answers): boolean => (!webConfigConns || !answers.path)
}
];
const questions: inquirer.Questions = [
{
name: 'path',
message: 'Use connections from Web.config file?',
type: 'confirm',
when: (): boolean => !!webConfigConns
}, {
name: 'server',
message: 'Server URL.',
default: (conn.server || undefined),
when: (answers): boolean => (!webConfigConns || !answers.path)
}, {
name: 'port',
message: 'Server port.',
default: (conn.port || undefined),
when: (answers): boolean => (!webConfigConns || !answers.path)
}, {
name: 'database',
message: 'Database name.',
default: (conn.database || undefined),
when: (answers): boolean => (!webConfigConns || !answers.path)
}, {
name: 'user',
message: 'Login username.',
default: (conn.user || undefined),
when: (answers): boolean => (!webConfigConns || !answers.path)
}, {
name: 'password',
message: 'Login password.',
default: (conn.password || undefined),
when: (answers): boolean => (!webConfigConns || !answers.path)
}, {
name: 'name',
message: 'Connection name.',
default: 'dev',
when: (answers): boolean => (!webConfigConns || !answers.path)
}
];

// prompt user for config options
inquirer.prompt(questions).then((answers: inquirer.Answers): void => {
if (answers.path) {
// use Web.config path
util.setConfig({ connections: webConfigFile });
} else {
util.setConfig({
connections: [new Connection({
name: answers.name,
server: answers.server,
port: answers.port,
database: answers.database,
user: answers.user,
password: answers.password
})]
});
}
});
// prompt user for config options
inquirer.prompt(questions).then((answers: inquirer.Answers): void => {
if (answers.path) {
// use Web.config path
util.setConfig({ connections: webConfigFile });
} else {
util.setConfig({
connections: [new Connection({
name: answers.name,
server: answers.server,
port: answers.port,
database: answers.database,
user: answers.user,
password: answers.password
})]
});
}
});
}
Loading

0 comments on commit 807b939

Please sign in to comment.