How to use the botbuilder-lg.TemplateExtensions.normalizePath function in botbuilder-lg

To help you get started, we’ve selected a few botbuilder-lg 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 microsoft / BotBuilder-Samples / samples / javascript_nodejs / language-generation / multilingual / dialogs / mainDialog.js View on Github external
return  (source, resourceId) => {
            let importPath = TemplateExtensions.normalizePath(resourceId);
            if (!path.isAbsolute(importPath)) {
                // get full path for importPath relative to path which is doing the import.
                importPath = TemplateExtensions.normalizePath(path.join(path.dirname(source), importPath));
            }

            var targetImportPath = importPath.replace('.lg', `.${locale}.lg`);

            // user can do some customized fallback here
            if (!fs.existsSync(targetImportPath) || !fs.statSync(targetImportPath).isFile()) {
                // fallback to itself
                if (!fs.existsSync(importPath) || !fs.statSync(importPath).isFile()) {
                    throw Error(`Could not find file: ${ importPath }`);
                }
            } else {
                importPath = targetImportPath;
            }

            const content = fs.readFileSync(importPath, 'utf-8');
            return { content, id: importPath };
github microsoft / BotBuilder-Samples / samples / javascript_nodejs / language-generation / multilingual / dialogs / mainDialog.js View on Github external
return  (source, resourceId) => {
            let importPath = TemplateExtensions.normalizePath(resourceId);
            if (!path.isAbsolute(importPath)) {
                // get full path for importPath relative to path which is doing the import.
                importPath = TemplateExtensions.normalizePath(path.join(path.dirname(source), importPath));
            }

            var targetImportPath = importPath.replace('.lg', `.${locale}.lg`);

            // user can do some customized fallback here
            if (!fs.existsSync(targetImportPath) || !fs.statSync(targetImportPath).isFile()) {
                // fallback to itself
                if (!fs.existsSync(importPath) || !fs.statSync(importPath).isFile()) {
                    throw Error(`Could not find file: ${ importPath }`);
                }
            } else {
                importPath = targetImportPath;
            }