Skip to content

Commit 2105c87

Browse files
committed
pass in configuration as object for cli method calls
1 parent 40bf15a commit 2105c87

File tree

10 files changed

+26
-21
lines changed

10 files changed

+26
-21
lines changed

lib/build/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ function parseAndBuild(dir, lines) {
1919
};
2020
return info_1.info({ dir: dir, result: result, lines: lines, index: index });
2121
}
22-
function build(dir, filePath, output) {
23-
if (output === void 0) { output = './coderoad.json'; }
22+
function build(_a) {
23+
var dir = _a.dir, filePath = _a.filePath, _b = _a.output, output = _b === void 0 ? './coderoad.json' : _b;
2424
filePath = path_1.join(dir, filePath);
2525
output = path_1.join(dir, output);
2626
if (!validate.filePath(filePath)) {

lib/cli.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ program
2323
.parse(process.argv);
2424
update_1.default();
2525
if (program.build) {
26-
var tutorial = program.args[0] || 'tutorial/tutorial.md';
26+
var tutorialPath = program.args[0] || 'tutorial/tutorial.md';
2727
var output = 'coderoad.json';
28-
process.stdout.write(chalk_1.grey("building coderoad.json for " + tutorial + "..."));
29-
if (!build_1.default(process.cwd(), tutorial, output)) {
28+
process.stdout.write(chalk_1.grey("building coderoad.json for " + tutorialPath + "..."));
29+
if (!build_1.default({ dir: process.cwd(), filePath: tutorialPath, output: output })) {
3030
result_1.fail();
3131
}
3232
}
3333
else if (program.create) {
3434
var packageName = program.args[0];
3535
process.stdout.write("Creating demo tutorial \"coderoad-" + packageName + "\"...");
36-
if (!create_1.default(process.cwd(), packageName)) {
36+
if (!create_1.default({ dir: process.cwd(), name: packageName })) {
3737
result_1.fail();
3838
}
3939
}
@@ -43,7 +43,7 @@ else if (program.search) {
4343
}
4444
else if (program.tutorials) {
4545
process.stdout.write("List of tutorial packages in this directory...");
46-
var tuts = tutorials_1.default(process.cwd());
46+
var tuts = tutorials_1.default({ dir: process.cwd() });
4747
if (!tuts) {
4848
result_1.fail();
4949
}
@@ -61,7 +61,7 @@ else if (program.tutorials) {
6161
}
6262
else if (program.publish) {
6363
var version = program.args[0];
64-
publish_1.default(version);
64+
publish_1.default({ version: version });
6565
}
6666
else if (program.validate) {
6767
if (!validate_1.default()) {

lib/create/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
var validate_1 = require('./validate');
33
var write_demo_1 = require('./write-demo');
44
var chalk_1 = require('chalk');
5-
function create(dir, name) {
5+
function create(_a) {
6+
var dir = _a.dir, name = _a.name;
67
return Promise.all([
78
validate_1.validatePackageName(name),
89
write_demo_1.createPackageJson(dir, name),

lib/publish/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"use strict";
22
var chalk_1 = require('chalk');
33
var validate_1 = require('./validate');
4-
function publish(version) {
4+
function publish(_a) {
5+
var version = _a.version;
56
validate_1.default(version);
67
process.stdout.write("Publishing package version \"" + version + "\"... \n");
78
console.log(chalk_1.yellow('Publish feature not implemented yet.\n'));

lib/tutorials/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
var chalk_1 = require('chalk');
33
var find_tutorials_1 = require('./find-tutorials');
44
var getJson_1 = require('../utils/getJson');
5-
function tutorials(dir) {
5+
function tutorials(_a) {
6+
var dir = _a.dir;
67
var pj = getJson_1.default(dir, 'package.json');
78
if (!pj) {
89
console.log(chalk_1.red("No package.json available"));

src/build/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ function parseAndBuild(dir: string, lines: string[]): CR.Output {
2121
return info({ dir, result, lines, index });
2222
}
2323

24-
export default function build(dir: string, filePath: string, output = './coderoad.json'): boolean {
24+
export default function build({
25+
dir, filePath, output = './coderoad.json'
26+
}): boolean {
2527

2628
filePath = join(dir, filePath);
2729
output = join(dir, output);

src/cli.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ program
2929
checkForUpdate();
3030

3131
if (program.build) {
32-
const tutorial = program.args[0] || 'tutorial/tutorial.md';
32+
const tutorialPath = program.args[0] || 'tutorial/tutorial.md';
3333
const output = 'coderoad.json';
34-
process.stdout.write(grey(`building coderoad.json for ${tutorial}...`));
34+
process.stdout.write(grey(`building coderoad.json for ${tutorialPath}...`));
3535
// run build
36-
if (!build(process.cwd(), tutorial, output)) {
36+
if (!build({ dir: process.cwd(), filePath: tutorialPath, output })) {
3737
fail();
3838
}
3939

4040
} else if (program.create) {
4141
const packageName = program.args[0];
4242
process.stdout.write(`Creating demo tutorial "coderoad-${packageName}"...`);
4343
// run create
44-
if (!create(process.cwd(), packageName)) {
44+
if (!create({ dir: process.cwd(), name: packageName })) {
4545
fail();
4646
}
4747

@@ -52,7 +52,7 @@ if (program.build) {
5252
} else if (program.tutorials) {
5353
// run find tutorials
5454
process.stdout.write(`List of tutorial packages in this directory...`);
55-
const tuts = tutorials(process.cwd());
55+
const tuts = tutorials({ dir: process.cwd() });
5656
if (!tuts) {
5757
fail();
5858
} else {
@@ -68,7 +68,7 @@ if (program.build) {
6868

6969
} else if (program.publish) {
7070
const version = program.args[0];
71-
publish(version);
71+
publish({ version });
7272

7373
} else if (program.validate) {
7474
if (!validate()) {

src/create/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {createPackageJson, createTutorialMd} from './write-demo';
44
import {red, yellow} from 'chalk';
55
// import build from '../build';
66

7-
export default function create(dir: string, name: string): boolean | Promise<boolean> {
7+
export default function create({ dir, name }): boolean | Promise<boolean> {
88

99
// npm package
1010
return Promise.all([

src/publish/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {yellow} from 'chalk';
22
import validateVersion from './validate';
33

4-
export default function publish(version: string): void {
4+
export default function publish({ version }): void {
55
validateVersion(version);
66
process.stdout.write(`Publishing package version "${version}"... \n`);
77
console.log(yellow('Publish feature not implemented yet.\n'));

src/tutorials/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {red} from 'chalk';
22
import findTutorials from './find-tutorials';
33
import getJson from '../utils/getJson';
44

5-
export default function tutorials(dir: string): string[] {
5+
export default function tutorials({ dir }): string[] {
66
const pj: PackageJson = getJson(dir, 'package.json');
77

88
if (!pj) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy