Skip to content

yandeu/extract

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Extract

Extract package.json properties.

Installation

npm install @yandeu/extract

Usage

CLI (example 1)

"name": "awesomepackage",
"version": "1.2.0",
"keywords": [
  "awesome",
  "fast"
],
"scripts": {
  "extract-version": "extract version VERSION.js",
  "test": "jest --coverage"
},

npm run extract-version will generate:

// VERSION.js
exports.VERSION = "1.2.0";

CLI (example 2)

Format file after extraction

"scripts": {
  "version": "extract version src/version.ts && prettier --write src/version.ts",
},

npm run version will extract the version and format it with prettier.

CLI (example 3)

"scripts": {
  "extract": "extract name keywords scripts.test src/const.ts",
},

npm run extract will generate:

// src/const.ts
export const NAME = "awesomepackage";
export const KEYWORDS = ["awesome", "fast"];
export const TEST = "jest --coverage";

Node.js

// index.cjs
const { extract } = require('extract')

extract(['name', 'version'], 'properties.js', false)
// index.mjs
import { extract } from 'extract/lib/extract.js'

extract(['name', 'version'], 'properties.js', false)
// index.ts
import { extract } from 'extract'

extract(['name', 'version'], 'properties.js', false)

License

MIT

About

📦 Extract package.json properties.

Resources

License

Stars

Watchers

Forks

Packages

No packages published