Last active
August 9, 2020 10:51
-
-
Save nathansmith/76f1d39f91ffe1d3fc01d5950731b15d to your computer and use it in GitHub Desktop.
Script to move NPM files from "dist" to package root
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { existsSync } = require('fs'); | |
const { execSync } = require('child_process'); | |
// ================ | |
// Check existence. | |
// ================ | |
const distFolderExists = existsSync('dist'); | |
const srcFolderExists = existsSync('src'); | |
// ============= | |
// CLI commands. | |
// ============= | |
const commandCopy = 'mv ./dist/* ./'; | |
const commandDelete = 'rm -rf ./dist'; | |
/* | |
===== | |
NOTE: | |
===== | |
We only want to do cleanup if we are in the | |
"distribution" mode. Ignore if "source" mode. | |
*/ | |
const doCleanup = distFolderExists && !srcFolderExists; | |
// Cleanup necessary? | |
if (doCleanup) { | |
execSync(commandCopy); | |
execSync(commandDelete); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment