Skip to content

Commit

Permalink
Attempt to find the plugin folder.
Browse files Browse the repository at this point in the history
  • Loading branch information
msaggiorato committed Jun 25, 2021
1 parent 29fd06c commit 650054a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion scripts/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,23 @@ let pluginAuthorFull = pluginAuthor +' <'+ pluginAuthorEmail + '>';
let sourcePath = path.join( process.cwd(), 'source-' + (new Date()).getTime() );

let sourcePluginPath = path.join( sourcePath, pluginSlug );
var targetPluginPath = path.join( process.cwd(), path.basename( sourcePluginPath ) );

let paths = [
'wp-content/plugins',
'plugins',
'.'
];

let basePath;
for( var i in paths ) {
let thisPath = path.resolve( path.join( process.cwd(), paths[i] ) );
if ( existsSync( thisPath ) ) {
basePath = thisPath;
break;
}
}

var targetPluginPath = path.join( basePath, path.basename( sourcePluginPath ) );

if ( existsSync( targetPluginPath ) ) {
console.warn( "Plugin already exists." );
Expand Down

0 comments on commit 650054a

Please sign in to comment.