File size: 448 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/**
 * packageExists
 *
 * Check whether the given package exist or not
 */

import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';

const __dirname = path.dirname( fileURLToPath( import.meta.url ) );

const packagePath = path.join( __dirname, '../../' );

const packageNames = fs.readdirSync( packagePath );

const packageExists = ( packageName ) => packageNames.includes( packageName );

export default packageExists;