Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Wxh16144 committed Oct 10, 2024
1 parent 86470b6 commit 25e6046
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions scripts/generate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node
const fs = require('fs-extra');
const path = require('path');
const semverValidRange = require('semver/ranges/valid');

/**
* 用 CLI 方式添加新的包或者 scope
Expand All @@ -23,6 +24,10 @@ const HELP = `
Usage:
npm run add --package={package name}:{version range}
npm run add --scope=@{scope name}
Debug mode:
Set DEBUG=true environment variable to use draft output and enable debug logging.
eg: DEBUG=true npm run add --package=urllib:*
`;

const DEBUG = !!process.env.DEBUG
Expand All @@ -45,6 +50,8 @@ function addPkg(input) {
// exits
if (PKG.allowPackages[name]) {
throw new Error(`Package ${name} already exists`);
} else if (!semverValidRange(version)) {
throw new Error(`Invalid version range: ${version}`);
}

DEBUG && console.log(`Add package: ${name}@${version}`);
Expand Down

0 comments on commit 25e6046

Please sign in to comment.