Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/*globals describe:true, it:true, expect:true, before:true, beforeEach:true, after:true, afterEach:true*/
/*jslint node: true */
var grunt = require('grunt');
var testDataFilename = grunt.template.process("<%= apigee_profiles[grunt.option('env')].apiproxy + '-' + grunt.option('env') + '-data' %>");
var async = require('async')
var chai = require('chai')
var assert = require('chai').assert
var expect = require('chai').expect
var request = require('request'), chaiHttp = require('chai-http');
var weatherData = require('./' + testDataFilename);
chai.use(chaiHttp);
describe('ForecastWeather Public API Test',function() {
"use strict";
before(function () {
// get OAuth 2.0 token
// console.log('initialize');
});
beforeEach(function () {
});
shell.exec(scp_cmd);
// 2) Build an SSH command
ssh_cmd = grunt.template.process(tpls.ssh, {
data: {
user: config.ssh_user,
host: config.ssh_host,
port: (typeof config.ssh_port === "undefined") ? '22' : config.ssh_port
}
});
// 3) Execute search-replace-db script on remote server
cmd = grunt.template.process( tpls.search_replace, {
data: {
scriptPath: "~/search-replace-db/",
host: config.host,
user: config.user,
pass: config.pass,
database: config.database,
search: search,
replace: replace,
flags: "" // dry run
}
});
cmd = ssh_cmd + " '" + cmd + "'";
// Return for reference and test suite purposes */
shell.exec(cmd);
RecessTask.prototype.run = function () {
var cb = this.task.async();
var files = this.task.files;
var options = this.task.options(RecessTask.DEFAULT_OPTIONS);
var banner = grunt.template.process(options.banner);
var footer = grunt.template.process(options.footer);
var reporter = false;
if (!files.length) {
grunt.log.writeln('No destinations specified.');
cb();
return;
}
// hook the reporting in...
if (options.report && options.report.reporter) {
reporter = {};
reporter.proto = require(__dirname + '/reporters/' + options.report.reporter + '.js');
reporter.mapping = options.report.mapping ? grunt.file.readJSON(options.report.mapping) : {};
reporter.inst = new reporter.proto(reporter.mapping);
options.compress = false;
options.compile = true;
function updateLibraryFiles(version) {
var versionRegex = /^(\s*\/\*![^\/]+?v)(\d+\.\d+\.\d+)(([^\n]+?)(\d+\/\d+\/\d+))?/
var today = grunt.template.today('yyyy/mm/dd')
var files = glob('lib/*.js')
files.forEach(updateLibraryFile)
function updateLibraryFile(filePath) {
var content = grunt.file.read(filePath)
if (versionRegex.test(content)) {
content = content.split(versionRegex)
content = content[1] + version + (content[4] || '') + (content[5] ? today : '') + (content[6] || '')
}
grunt.file.write(filePath, content)
}
}
copyToGem: function() {
var versionRb = grunt.template.process(
grunt.file.read("grunt/templates/version.rb.jst"),
{ data: { jasmineVersion: nodeToRuby(global.jasmineVersion) }});
grunt.file.write(gemLib("version.rb"), versionRb);
}
};
function build(name, filename) {
var srcFile = `vendor/${filename}.js`;
var destFile = `build/${filename}.js`;
var destFileMin = `build/${filename}.min.js`;
var templateData = {
package: name,
version: grunt.config.data.pkg.version,
};
var header = grunt.template.process(
LICENSE_TEMPLATE,
{data: templateData}
);
var src = grunt.file.read(srcFile);
var srcMin = UglifyJS.minify(src, {fromString: true}).code;
grunt.file.write(destFile, header + src);
grunt.file.write(destFileMin, header + srcMin);
}
function license() {
var currentYear = "" + new Date(Date.now()).getFullYear();
return grunt.template.process(
grunt.file.read("grunt/templates/licenseBanner.js.jst"),
{data: {currentYear: currentYear}});
}
utils.template = function (tmpl, options) {
return grunt.template.process(tmpl, options);
};
exports.copyright = function (startYear) {
var name = config.author.name || config.author;
var today = grunt.template.today('yyyy');
var date = startYear ? startYear + '-' + today : today;
return 'Copyright (c) ' + date + ' ' + name + ', contributors.';
};
processGruntTemplate: function (string) {
var isProcessTemplateTrue = true;
if (grunt.task.current.data &&
grunt.task.current.data.options &&
typeof grunt.task.current.data.options.processTemplates !== 'undefined' &&
grunt.task.current.data.options.processTemplates === false) {
isProcessTemplateTrue = false;
}
return isProcessTemplateTrue ? grunt.template.process(string) : string;
}