Skip to content

Commit

Permalink
prepare for first npm release
Browse files Browse the repository at this point in the history
  • Loading branch information
amirsaeed671 committed Dec 31, 2022
1 parent 214556a commit 4ed2894
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
3 changes: 2 additions & 1 deletion bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
Object.defineProperty(exports, "__esModule", { value: true });
const child_process_1 = require("child_process");
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const args = [
{
name: "--meta",
Expand Down Expand Up @@ -37,7 +38,7 @@ function validateArguments(cliArgs) {
}
function generateTemplate({ title, id, date, }) {
const fileContent = fs_1.default
.readFileSync("./src/template/template.md", "utf8")
.readFileSync(path_1.default.join(__dirname, "../", "templates", "blog-post.md"), "utf8")
.replace(/\{\{title\}\}/g, title)
.replace(/\{\{date\}\}/g, date);
(0, child_process_1.exec)(`echo '${fileContent}' > ${process.cwd()}/${id}.md`);
Expand Down
22 changes: 18 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
{
"name": "matter-gen-cli",
"name": "@amirsaeed671/matter-gen-cli",
"version": "0.0.1",
"main": "./bin/index.js",
"main": "./src/index.ts",
"description": "generate md file with meta data for gray-matter",
"scripts": {
"build": "npx tsc"
"build": "npx tsc",
"publish": "yarn run build && npm publish"
},
"publishConfig": {
"access": "public"
},
"bin": {
"@amirsaeed671/matter-gen-cli": "./bin/index.js",
"matter-gen-cli": "./bin/index.js"
},
"repository": "https://github.com/amirsaeed671/matter-gen-cli.git",
Expand All @@ -15,5 +20,14 @@
"devDependencies": {
"@types/node": "^18.11.18",
"typescript": "^4.9.4"
}
},
"keywords": [
"cli",
"matter-gen-cli"
],
"files": [
"bin/",
"src/",
"templates/"
]
}
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { exec } from "child_process";
import fs from "fs";
import path from "path";

const args = [
{
Expand Down Expand Up @@ -52,7 +53,10 @@ function generateTemplate({
id: string;
}): void {
const fileContent = fs
.readFileSync("./src/template/template.md", "utf8")
.readFileSync(
path.join(__dirname, "../", "templates", "blog-post.md"),
"utf8"
)
.replace(/\{\{title\}\}/g, title)
.replace(/\{\{date\}\}/g, date);

Expand Down
File renamed without changes.

0 comments on commit 4ed2894

Please sign in to comment.