Flag when plugin is release mode or development

If a plugin is in development I’d like to run some debug code run but if a plugin is released I’d like to turn that code off.

Is there a flag to check that?

Use Case
Nate is creating his first plugin. He uses debug tools to help him debug. But he wants to turn those tools off when he release build.

Not a flag, as far as I’m aware of. It might be feasible, though (I can’t test that right now) to check this via fileSystemProvider.getPluginFolder(). For example, it might be as easy as checking whether this includes 'develop' (again: not tested, but it came to my mind while thinking about it)…

1 Like

Interesting. That sounds like it would work.

During development the plugin folder shows “develop” as the parent directory:

const filesystem = require("uxp").storage;
const folder = await filesystem.localFileSystem.getPluginFolder();

Results in:

/Users/user/Library/Application Support/Adobe/Adobe XD/develop/my-plugin/

In production there is no develop folder (at least not in the default install path):

/Users/user/Library/Application Support/Adobe/Adobe XD/plugin_settings/abc123456/

This function checks for the develop folder at the parent directory:

async function isDesignMode() {
	const filesystem = require("uxp").storage;
	const pluginFolder = await filesystem.localFileSystem.getPluginFolder();
	const nativePath = pluginFolder.nativePath;
	const isMac = require("os").platform()=="darwin";
	const delimiter = isMac ? "/" : "\\";
	var folders = nativePath.split(delimiter);
	var folderName = "develop";
	var filtered = folders.filter((path)=> {return path});
	var numberOfFolders = filtered.length;
	var index = filtered.indexOf(folderName);
	var offsetOfDevelopFolder = -2;

	if (index==numberOfFolders+offsetOfDevelopFolder) {
		return true;

	return false;

var designMode = await isDesignMode();
console.log (designMode); // true

I haven’t tested this on Windows or in production.

Hmmm. Normally I’d do this through an environment variable during my build process. This can then be injected at build time into my project so that when I build for release, the value is set one way, and when I build for debug, it’s another.

Another option is to look for the presence of a file that you only provide for production or debug, and switch based on that. Might be better than looking for the folder name itself (I’m not 100% sure if it is localized or not…, and it could be tricked anyway).