Skip to content

Commit

Permalink
add more robust implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
anshgoyalevil committed Aug 16, 2023
1 parent adccd3a commit a6c1d52
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 112 deletions.
89 changes: 0 additions & 89 deletions scripts/generateDepcheckrc.js

This file was deleted.

13 changes: 12 additions & 1 deletion scripts/generateDepcheckrcJaegerUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

/* eslint-disable import/no-extraneous-dependencies */
const fs = require('fs');
const path = require('path');
const { babelConfiguration } = require('../packages/jaeger-ui/test/babel-transform');

const packageNames = [
Expand All @@ -34,4 +35,14 @@ const depcheckrcContent = {
'ignore-dirs': ['build'],
};

fs.writeFileSync('packages/jaeger-ui/.depcheckrc.json', JSON.stringify(depcheckrcContent, null, 2));
// Use the argument provided to the script as the output file path
const outputFile = process.argv[2];

if (!outputFile) {
console.error('Usage: node generateDepcheckrcJaegerUI.js <outputFile>');
process.exit(1);
}

const depcheckrcPath = path.resolve(__dirname, outputFile);

fs.writeFileSync(depcheckrcPath, JSON.stringify(depcheckrcContent, null, 2));
13 changes: 12 additions & 1 deletion scripts/generateDepcheckrcPlexus.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

/* eslint-disable import/no-extraneous-dependencies */
const fs = require('fs');
const path = require('path');
const getBabelConfig = require('../packages/plexus/babel.config');

const babelConfiguration = getBabelConfig({
Expand Down Expand Up @@ -44,4 +45,14 @@ const depcheckrcContent = {
ignores: [...packageNames, ...otherPackages],
};

fs.writeFileSync('packages/plexus/.depcheckrc.json', JSON.stringify(depcheckrcContent, null, 2));
// Use the argument provided to the script as the output file path
const outputFile = process.argv[2];

if (!outputFile) {
console.error('Usage: node generateDepcheckrcJaegerUI.js <outputFile>');
process.exit(1);
}

const depcheckrcPath = path.resolve(__dirname, outputFile);

fs.writeFileSync(depcheckrcPath, JSON.stringify(depcheckrcContent, null, 2));
30 changes: 9 additions & 21 deletions scripts/run-depcheck.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
#!/bin/sh
# This script runs depcheck on two different packages: 'jaeger-ui' and 'plexus'
set -ex

# Run depcheck for the 'jaeger-ui' package
(
node scripts/generateDepcheckrcJaegerUI.js && # Generate depcheckrc for 'jaeger-ui'
depcheck packages/jaeger-ui && # Run depcheck on 'jaeger-ui'
rm -f packages/jaeger-ui/.depcheckrc.json # Clean up generated depcheckrc
) || (
EXIT_CODE=$? # Store the exit code from the previous command
rm -f packages/jaeger-ui/.depcheckrc.json # Clean up generated depcheckrc
exit $EXIT_CODE # Exit with the stored exit code
)
# Create a temporary depcheckrc file for 'jaeger-ui'
tempfile_jaeger=$(mktemp /tmp/depcheckrc.XXXXXX.json)
node scripts/generateDepcheckrcJaegerUI.js "$tempfile_jaeger"
depcheck packages/jaeger-ui --config "$tempfile_jaeger"

# Run depcheck for the 'plexus' package
(
node scripts/generateDepcheckrcPlexus.js && # Generate depcheckrc for 'plexus'
depcheck packages/plexus && # Run depcheck on 'plexus'
rm -f packages/plexus/.depcheckrc.json # Clean up generated depcheckrc
) || (
EXIT_CODE=$? # Store the exit code from the previous command
rm -f packages/plexus/.depcheckrc.json # Clean up generated depcheckrc
exit $EXIT_CODE # Exit with the stored exit code
)
# Create a temporary depcheckrc file for 'plexus'
tempfile_plexus=$(mktemp /tmp/depcheckrc.XXXXXX.json)
node scripts/generateDepcheckrcPlexus.js "$tempfile_plexus"
depcheck packages/plexus --config "$tempfile_plexus"

0 comments on commit a6c1d52

Please sign in to comment.