Skip to content

Commit

Permalink
cirodown --generate
Browse files Browse the repository at this point in the history
Fix #7
  • Loading branch information
cirosantilli committed Mar 30, 2020
1 parent 2e33a96 commit 46ca056
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -12,4 +12,6 @@ cirodown.embed.min.css
cirodown.js
cirodown.local.min.css
cirodown.min.css
tmp
tmp.*
*.tmp
32 changes: 32 additions & 0 deletions cirodown
Expand Up @@ -352,6 +352,7 @@ function* walk_files_recursively(file_or_dir, skip_basenames) {
// CLI options.
commander.option('--body-only', 'output only the content inside the HTLM body element', false);
commander.option('--dry-run', "don't run most external commands, see: https://github.com/cirosantilli/linux-kernel-module-cheat/tree/6d0a900f4c3c15e65d850f9d29d63315a6f976bf#dry-run-to-get-commands-for-your-project", false);
commander.option('--generate', 'http://cirosantilli.com/cirodown#generate', false);
commander.option('--help-macros', 'print the metadata of all macros to stdout in JSON format. https://cirosantilli.com/cirodown/#', false);
commander.option('--html-embed', 'http://cirosantilli.com/cirodown#html-embed', false);
commander.option('--html-single-page', 'http://cirosantilli.com/cirodown#html-single-page', false);
Expand Down Expand Up @@ -423,6 +424,37 @@ if (commander.helpMacros) {
show_tokens: commander.showTokensInside,
show_tokenize: commander.showTokenize,
};
if (commander.generate) {
// Generate package.json.
const package_json = JSON.parse(fs.readFileSync(cirodown_nodejs.PACKAGE_PACKAGE_JSON_PATH).toString());
const package_json_str = `{
"dependencies": {
"cirodown": "${package_json.version}"
}
}
`;
fs.writeFileSync(path.join('package.json'), package_json_str);

// Generate .gitignore.
let gitignore_new = '';
const gitignore = fs.readFileSync(cirodown_nodejs.GITIGNORE_PATH, ENCODING);
for (const line of gitignore.split('\n')) {
if (line === '') {
break;
}
gitignore_new += line + '\n';
}
fs.writeFileSync('.gitignore', gitignore_new);

// Generate README.ciro.
const readme_cirodown_str = `\\h[1][Cirodown hello world]
Hello!
`;
fs.writeFileSync(path.join('README.ciro'), readme_cirodown_str);

process.exit(0);
}
let convert_input_options = {
commander: commander,
encoding: ENCODING,
Expand Down
2 changes: 2 additions & 0 deletions nodejs.js
Expand Up @@ -21,6 +21,8 @@ const PACKAGE_NODE_MODULES_PATH = path.join(PACKAGE_PATH, 'node_modules');
exports.PACKAGE_NODE_MODULES_PATH = PACKAGE_NODE_MODULES_PATH;
const PACKAGE_PACKAGE_JSON_PATH = path.join(PACKAGE_PATH, 'package.json');
exports.PACKAGE_PACKAGE_JSON_PATH = PACKAGE_PACKAGE_JSON_PATH;
const GITIGNORE_PATH = path.join(PACKAGE_PATH, '.gitignore');
exports.GITIGNORE_PATH = GITIGNORE_PATH;
const PACKAGE_SASS_BASENAME = PACKAGE_NAME + '.scss';
exports.PACKAGE_SASS_BASENAME = PACKAGE_SASS_BASENAME;
const LOCAL_INCLUDES = [
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -18,6 +18,7 @@
"mocha-list-tests": "1.0.2"
},
"files": [
".gitignore",
"cirodown",
"cirodown.js",
"cirodown.embed.min.css",
Expand Down

0 comments on commit 46ca056

Please sign in to comment.