Skip to content

Commit

Permalink
code optimized
Browse files Browse the repository at this point in the history
  • Loading branch information
NazmusSayad committed Jul 28, 2024
1 parent 683e520 commit f1cabea
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "npmize",
"description": "Let's create an npm package without worrying about anything.",
"version": "0.0.9",
"version": "0.0.10",
"bin": "./dist/index.js",
"scripts": {
"lab": "nodemon ./src/__lab.ts",
Expand All @@ -13,7 +13,7 @@
"@babel/parser": "^7.20.7",
"ansi-colors": "^4.1.3",
"lskit": "^1.0.0",
"noarg": "^1.0.1",
"noarg": "^1.0.3",
"shelljs": "^0.8.5"
},
"devDependencies": {
Expand Down
14 changes: 8 additions & 6 deletions src/program/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@ export default function (basePath: string, options: InitOptions) {
if (options.writePackageJSON) {
const data = packageJSON.read(basePath)

data.name = path.basename(basePath)
data.version = '0.0.0'
data.name ??= path.basename(basePath)
data.version ??= '0.0.0'

data.scripts ??= {}
data.scripts.dev = 'npmize dev'
data.scripts.build = 'npmize build'

delete data.main
delete data.module
delete data.exports

data.main = './dist/index.cjs'
data.module = './dist/index.mjs'
data.exports ??= {}
data.exports = {
'.': {
require: './dist/index.cjs',
Expand All @@ -36,9 +40,7 @@ export default function (basePath: string, options: InitOptions) {
}

if (options.installPackages) {
shelljs
.cd(basePath)
.exec('npm install npmize typescript --save-dev --no-package-lock')
shelljs.cd(basePath).exec('npm install npmize typescript --save-dev')
} else {
console.log(ansiColors.bgGreen(' INFO: '), 'TypeScript is disabled')
}
Expand Down

0 comments on commit f1cabea

Please sign in to comment.