Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it( 'ignores a package that is not a plugin', async () => {
vol.mkdirpSync( localPluginDir ); // local
vol.writeFileSync( localPluginPackageFile, JSON.stringify( pkg ) ); // local
const pkg2 = { ... pkg }; // copy properties
pkg2.name += '-non-plugin';
pkg2[ PLUGIN_PROPERTY ] = undefined; // removes the expected property
vol.mkdirpSync( join( localModulesDir, pkg2.name ) );
vol.writeFileSync( join( localModulesDir, pkg2.name, PKG_FILENAME ), JSON.stringify( pkg2 ) );
const finder: PackageBasedPluginFinder = new PackageBasedPluginFinder( currentDir, fs );
const pluginData: PluginData[] = await finder.find();
expect( pluginData ).toHaveLength( 1 );
} );
it( 'prefers local than global', async () => {
vol.mkdirpSync( localPluginDir ); // local
vol.writeFileSync( localPluginPackageFile, JSON.stringify( pkg ) ); // local
const pkg2 = { ... pkg }; // copy properties
vol.mkdirpSync( globalPluginDir ); // global
vol.writeFileSync( globalPluginPackageFile, JSON.stringify( pkg2 ) ); // global
const finder: PackageBasedPluginFinder = new PackageBasedPluginFinder( currentDir, fs );
const pluginData: PluginData[] = await finder.find();
expect( pluginData ).toHaveLength( 1 );
const first = pluginData[ 0 ];
expect( first.name ).toEqual( pkg.name );
} );
it( 'ignores a package that is not a plugin', async () => {
vol.mkdirpSync( localPluginDir ); // local
vol.writeFileSync( localPluginPackageFile, JSON.stringify( pkg ) ); // local
const pkg2 = { ... pkg }; // copy properties
pkg2.name += '-non-plugin';
pkg2[ PLUGIN_PROPERTY ] = undefined; // removes the expected property
vol.mkdirpSync( join( localModulesDir, pkg2.name ) );
vol.writeFileSync( join( localModulesDir, pkg2.name, PKG_FILENAME ), JSON.stringify( pkg2 ) );
const finder: PackageBasedPluginFinder = new PackageBasedPluginFinder( currentDir, fs );
const pluginData: PluginData[] = await finder.find();
expect( pluginData ).toHaveLength( 1 );
} );