How to use the n8n-core.UserSettings.getUserN8nFolderCustomExtensionPath function in n8n-core

To help you get started, we’ve selected a few n8n-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github n8n-io / n8n / packages / node-dev / src / Build.ts View on Github external
export async function buildFiles (options?: IBuildOptions): Promise {
	options = options || {};

	// Get the path of the TypeScript cli of this project
	const tscPath = join(__dirname, '../../node_modules/typescript/bin/tsc');

	const tsconfigData = await createCustomTsconfig();

	const outputDirectory = options.destinationFolder || UserSettings.getUserN8nFolderCustomExtensionPath();

	// Supply a node base path so that it finds n8n-core and n8n-workflow
	const nodeModulesPath = join(__dirname, '../../node_modules/');
	let buildCommand = `${tscPath} --p ${tsconfigData.path} --outDir ${outputDirectory} --rootDir ${process.cwd()} --baseUrl ${nodeModulesPath}`;
	if (options.watch === true) {
		buildCommand += ' --watch';
	}

	let buildProcess: ChildProcess;
	try {
		buildProcess = spawn('node', buildCommand.split(' '), { windowsVerbatimArguments: true, cwd: process.cwd() });

		// Forward the output of the child process to the main one
		// that the user can see what is happening
		buildProcess.stdout.pipe(process.stdout);
		buildProcess.stderr.pipe(process.stderr);
github n8n-io / n8n / packages / cli / src / LoadNodesAndCredentials.ts View on Github external
}

		this.excludeNodes = config.get('nodes.exclude');

		// Get all the installed packages which contain n8n nodes
		const packages = await this.getN8nNodePackages();

		for (const packageName of packages) {
			await this.loadDataFromPackage(packageName);
		}

		// Read nodes and credentials from custom directories
		const customDirectories = [];

		// Add "custom" folder in user-n8n folder
		customDirectories.push(UserSettings.getUserN8nFolderCustomExtensionPath());

		// Add folders from special environment variable
		if (process.env[CUSTOM_EXTENSION_ENV] !== undefined) {
			const customExtensionFolders = process.env[CUSTOM_EXTENSION_ENV]!.split(';');
			customDirectories.push.apply(customDirectories, customExtensionFolders);
		}

		for (const directory of customDirectories) {
			await this.loadDataFromDirectory('CUSTOM', directory);
		}
	}
github n8n-io / n8n / packages / node-dev / commands / build.ts View on Github external
} from '../src';

export class Build extends Command {
	static description = 'Builds credentials and nodes and copies it to n8n custom extension folder';

	static examples = [
		`$ n8n-node-dev build`,
		`$ n8n-node-dev build --destination ~/n8n-nodes`,
		`$ n8n-node-dev build --watch`,
	];

	static flags = {
		help: flags.help({ char: 'h' }),
		destination: flags.string({
			char: 'd',
			description: `The path to copy the compiles files to [default: ${UserSettings.getUserN8nFolderCustomExtensionPath()}]`,
		}),
		watch: flags.boolean({
			description: 'Starts in watch mode and automatically builds and copies file whenever they change',
		}),
	};

	async run() {
		const { flags } = this.parse(Build);

		this.log('\nBuild credentials and nodes');
		this.log('=========================');

		try {
			const options: IBuildOptions = {};

			if (flags.destination) {