{"size": 1956, "ext": "js", "max_stars_repo_path": "scriptWrapper.js", "max_stars_repo_name": "fpellet/jquery.ajaxFile", "max_stars_repo_stars_event_min_datetime": "2016-06-01T02:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2016-06-01T02:53:42.000Z", "max_issues_repo_path": "scriptWrapper.js", "max_issues_repo_name": "fpellet/jquery.ajaxFile", "max_issues_repo_issues_event_min_datetime": "2016-06-14T07:19:54.000Z", "max_issues_repo_issues_event_max_datetime": "2016-07-10T16:35:45.000Z", "max_forks_repo_path": "scriptWrapper.js", "max_forks_repo_name": "fpellet/jquery.ajaxFile", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 39.12, "max_line_length": 122, "alphanum_fraction": 0.4442740286}
﻿'use strict';

var fs = require('fs');
var wrapJs = require("gulp-wrap-js");

var getCurrentVersion = function () {
    var packageConfig = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
    return packageConfig.version;
};

var generateHead = function() {
    return "/*!" + "\r\n" +
        " * AjaxFile.js - V" + getCurrentVersion() + "\r\n" +
        " * Project repository: https://github.com/fpellet/jquery.ajaxFile" + "\r\n" +
        " * Licensed under the MIT license" + "\r\n" +
        " */" + "\r\n";
};

var preScript = "(function (factory) {" + "\r\n" +
                    "if (typeof define === 'function' && define.amd) {" + "\r\n" +
                    "    define(['jquery'], factory);" + "\r\n" +
                    "} else {" + "\r\n" +
                    "    window.AjaxFile = factory( (typeof(jQuery) != 'undefined') ? jQuery : window.Zepto );" + "\r\n" +
                    "}" + "\r\n" +
                "} (function ($) {" + "\r\n" +
                "    \"use strict\";" + "\r\n";
var postScript = "\r\n" +
                 "return ajaxFile;" + "\r\n" +
                 "}));" + "\r\n";

var generateTemplate = function() {
    return generateHead() + preScript + '%= body %' + postScript;
};

exports.wrap = function() {
    return wrapJs(generateTemplate());
};

exports.wrapForKnockoutPlugin = function () {
    var template = generateHead() + "(function (factory) {" + "\r\n" +
                    "if (typeof define === 'function' && define.amd) {" + "\r\n" +
                    "    define(['jquery', 'knockout'], factory);" + "\r\n" +
                    "} else {" + "\r\n" +
                    "   factory( (typeof(jQuery) != 'undefined') ? jQuery : window.Zepto, ko);" + "\r\n" +
                    "}" + "\r\n" +
                "} (function ($, ko) {" + "\r\n" +
                "    \"use strict\";" + "\r\n" + '%= body %' + "\r\n" +
                 "}));" + "\r\n";
    return wrapJs(template);
};