Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

next-format

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-format - npm Package Compare versions

Comparing version 0.0.11 to 0.0.12

2

package.json
{
"name": "next-format",
"version": "0.0.11",
"version": "0.0.12",
"description": "Opinionated es-next formatter inspired by golang fmt.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/pre63/next-format",

@@ -12,5 +12,5 @@ # next-format

## usage
In any directory contining `.js` files run `nextformat` in the command line and all the javascript files will be formatted.
In any directory contining `.js` files run `nextformat [path]` in the command line and all the javascript files will be formatted. `path` is optional.
``` bash
> nextformat
> nextformat ./src/
```

@@ -17,0 +17,0 @@

@@ -5,5 +5,6 @@ const compose = require('oncha/compose').default

const path = require('path')
const crypto = require('crypto')
// IMPURE
const walker = dir => {
const walker = lastRunTime => dir => {
const many = []

@@ -17,5 +18,8 @@ const walkSync = d => {

const p = `${d}/${file}`
if (fs.statSync(p).isDirectory()) {
const stat = fs.statSync(p)
const now = new Date().getTime()
if (stat.isDirectory()) {
walkSync(p)
} else {
} else if (stat.mtime.getTime() > lastRunTime || stat.ctime.getTime() > lastRunTime) {
many.push(path.relative(process.cwd(), p))

@@ -34,6 +38,15 @@ }

const format = file => write(file)(next(read(file)))
const format = file => {
const init = read(file)
const res = next(init)
const plurial = count => (count > 1 ? 's' : '')
init != res && write(file)(res)
}
const plural = count => (count === 1 ? '' : 's')
const setLastRunTime = path => write(path)(Date.now())
const getLastRunTime = path => fs.existsSync(path) ? read(path) : 0
// PROGRAM

@@ -47,8 +60,12 @@ const selectPathArg = () => (process.argv[2] || '').concat('/')

const count = walker(selectPath())
const lastRunPath = path.resolve(__dirname, '../.last_' + crypto.createHash('md5').update(selectPath()).digest('hex'))
const count = walker(getLastRunTime(lastRunPath))(selectPath())
.filter(f => f.toLowerCase().endsWith('.js'))
.map(format).length
setLastRunTime(lastRunPath)
const seconds = (Date.now() - startDate) / 1000
console.log(`Formatted ${count} file${plurial(count)} in ${seconds}s.`)
console.log(`Formatted ${count} file${plural(count)} in ${seconds}s.`)

@@ -17,5 +17,3 @@ const assert = require('assert')

const createTestData = compose(
createTestObject,
split('-----------------------------------'))
const createTestData = compose(createTestObject, split('-----------------------------------'))

@@ -22,0 +20,0 @@ const tryCatch = func => {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc