diff --git a/use-shopping-cart/package.json b/use-shopping-cart/package.json index 00ad6ba2..7cc4e1c7 100644 --- a/use-shopping-cart/package.json +++ b/use-shopping-cart/package.json @@ -1,6 +1,6 @@ { "name": "use-shopping-cart", - "version": "3.0.1", + "version": "3.0.2", "description": "Shopping cart state and logic for Stripe", "author": "dayhaysoos", "license": "MIT", diff --git a/use-shopping-cart/rollup.config.js b/use-shopping-cart/rollup.config.js index eee4ff63..aa006636 100644 --- a/use-shopping-cart/rollup.config.js +++ b/use-shopping-cart/rollup.config.js @@ -6,7 +6,8 @@ import replace from '@rollup/plugin-replace' import externals from 'rollup-plugin-node-externals' import visualizer from 'rollup-plugin-visualizer' -import { promises as fs } from 'fs' +import { promises as fs, existsSync } from 'fs' + import path from 'path' import pkg from './package.json' @@ -42,6 +43,23 @@ function copyTypes() { ) console.error(error) } + + try { + await fs.copyFile( + path.join(process.cwd(), 'core', 'index.d.ts'), + path.join(process.cwd(), 'dist', 'index.d.ts') + ) + } catch (error) { + console.log( + `Unable to copy ${path.join( + process.cwd(), + 'core', + 'index.d.ts' + )} ${path.join(process.cwd(), 'dist', 'index.d.ts')}` + ) + + console.error(error) + } } } } @@ -60,6 +78,13 @@ function clearDist() { if (cleared) return cleared = true + if (existsSync(path.resolve('dist'))) { + console.log('dist folder exists') + } else { + console.log('dist folder unavailable, creating one...') + fs.mkdir('dist') + } + try { await fs.rm(path.resolve('dist'), { recursive: true }) await fs.mkdir(path.resolve('dist'))