npm.click
Version:
Hi!
32 lines (28 loc) • 1.26 kB
JavaScript
const Ascii = require('ascii-table')
const moment = require('moment')
module.exports=async function(path){
if(!path)throw new TypeError("Please specify your path to your package.json ")
const parsed = require(path);
let version = parsed.version.split(".")
version[version.length-1] = (~~version[version.length-1]+1).toString()
parsed.version = version.join(".")
let name = parsed.name
parsed.name = name;
let desc = parsed.description
parsed.description=desc
let main = parsed.main
parsed.main = main
let author = parsed.author
parsed.author = author
let license = parsed.license
parsed.license=license
const fs = require('fs');
fs.writeFileSync(path, JSON.stringify(parsed,null,2));
const cp = require('child_process')
cp.execSync(`npm publish`)
let table = new Ascii("Status")
table.setHeading(`Name`,`Version`,`Description`,`Main file`,`Author`,`License`,`Date/Time`)
table.addRow(parsed.name,parsed.version,parsed.description,parsed.main,parsed.author,parsed.license,moment().format('MMMM Do YYYY, h:mm:ss a'))
console.log(table.toString())
fs.appendFileSync(`${__dirname}/npm.click.txt`,`${table.toString()}\n`)
}