1.0.2 • Published 3 years ago

codep v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

CoDep

Copy your frontend dependencies directly into your assets.

Features

Install

npm i -D codep

Usage

import { Codep } from "codep"

await new Codep("assets/vendor", {
  exclude: ["jquery", "modernizr"]
}).paste()

API

const codep = new Codep(outDir, options?)

outDir

Type : string

Specify an output folder for all copied files

options

Type: object

PropertyTypeDefaultDescription
sourcestringnode_modulesSpecify the node modules directory
pkgstringpackage.jsonSpecify the json file location
flattenDistbooleantrueKeep the dist folder or flatten in the root folder from each dependency
excludestring\|array[]Specify the name of the dependencies you don't want to copy, e.g. ['jquery', 'modernizr']
extstring\|arrayOnly copied files with the specified extension. Use * to grab all files from dependencies
overwritebooleanfalseDo you want to overwrite existing dependencies in the outdir?
devDependenciesbooleanfalseShould you need to grab devDependencies as well?

ext Default: js,jsx,ts,tsx,css,scss,less,stylus,map,eot,woff,woff2,ttf,svg,png,jpg,jpeg

codep.paste()

Write source files to outDir asynchronously.

;(async () => {
  await codep.paste()
})()

Optimizations

Handle progress reports the way you want.

import { Codep } from "codep"

// initialize Codep
const codep = new Codep("assets/vendor", {
  exclude: ["jquery", "modernizr"]
})

// handle reports or just ignore this block
codep.on("progress", data => {
  // doing things on progress
})

// copying
;(async () => {
  try {
    await codep.paste()
  } catch (error) {
    throw error
  }
})()

codep.on('progress', handler)

handler(data)

Type: Function

data

Type: Manifest

Manifest is an object with properties below:

PropertyType
successnumber
failednumber
processednumber
percentstring
vendorsstring[]
totalFilesnumber
logLog

Related