private addData()

in templates/legacy/windows-admin-center-extension-template/gulps/gulp-ps-code/ps-code-convert.ts [71:118]


    private addData(current: { [index: string]: string }): void {
        let keys = Object.keys(current);
        for (let key of keys) {
            let script = '';
            let content: string = current[key];
            let name = this.jsonName(key);
            script = '##' + name + '##:' + key + '\n';
            let removeComments = this.options.noComments;
            if (content.indexOf(PsCodeConverter.removeCommentsFalse) > 0) {
                removeComments = false;
            } else if (content.indexOf(PsCodeConverter.removeCommentsTrue) > 0) {
                removeComments = true;
            }

            let skipping = false;
            let lines = content.split('\r');
            lines.forEach((value, index, array) => {
                let text = value.replace('\n', '');
                if (removeComments) {
                    let process = true;
                    text = text.trim();
                    if (text.startsWith(PsCodeConverter.commentStart)) {
                        skipping = true;
                    }

                    if (skipping) {
                        process = false;
                        if (text.endsWith(PsCodeConverter.commentEnd)) {
                            skipping = false;
                        }
                    }

                    if (process && !text.startsWith(PsCodeConverter.comment) && text.length > 0) {
                        script += text + '\n';
                    }
                } else {
                    script += text + '\n';
                }

            });
            let data = JSON.stringify(script);
            data = this.replaceAll(data, '\'', '\\u0027');
            data = this.replaceAll(data, '<', '\\u003c');
            data = this.replaceAll(data, '>', '\\u003e');
            data = this.replaceAll(data, '&', '\\u0026');
            this.addToContent(name, data, 1);
        }
    }