function()

in package.js [52:137]


        function(taskJson, encoding, done) {
            if (!fs.existsSync(taskJson)) {
                new gutil.PluginError('PackageTask', 'Task json cannot be found: ' + taskJson.path);
            }

            if (taskJson.isNull() || taskJson.isDirectory()) {
                this.push(taskJson);
                return callback();
            }

            var taskDirPath = path.dirname(taskJson.path);
            var folderName = path.basename(taskDirPath);
            var jsonContents = taskJson.contents.toString();
            var task = {};
            try {
                task = JSON.parse(jsonContents);
            }
            catch (err) {
                done(createError(folderName + ' parse error: ' + err.message));
                return;
            }

            var targetPath;

            validateTask(folderName, task)
            .then(function() {
                // Copy the task to the layout folder.
                targetPath = path.join(currentExtnRoot, "Src", "Tasks", task.name);
                shell.mkdir('-p', targetPath);
                shell.rm(path.join(targetPath, '*.csproj'));
                shell.rm(path.join(targetPath, '*.md'));
                // Path to UI contribution files
                uiPath = path.join(currentExtnRoot, "Src", "UIContribution");
                // Statically link the required internal common modules.
                var taskDeps;
                if ((taskDeps = commonDeps[folderName])) {
                    taskDeps.forEach(function (dep) {
                        gutil.log('Linking ' + dep.module + ' into ' + folderName);
                        var src = path.join(commonSrc, dep.module, "Src/");
                        var dest = path.join(targetPath, dep.dest);
                        shell.mkdir('-p', dest);
                        fs.copy(src, dest, "*", function (err) {
                            if (err) return console.error(err) 
                        })
                    })
                }
                var externals = require('./externals.json');
                if (task.execution['Node']) {
                     var doNotCache = false;
                     externals['no-cache'].forEach(function(ext){
                         if(ext == task.name) {
                             doNotCache = true;
                         }
                     });
                     
                     if(doNotCache) {
                        util.buildNodeTask(taskDirPath, targetPath); 
                         // For building UI contribution using webpack
                         if(fs.existsSync(uiPath) && fs.statSync(uiPath).isDirectory()) {
                            util.buildUIContribution(uiPath,uiPath);
                        }
                     } else {

                        // Determine the vsts-task-lib version.
                        var libVer = externals.npm['vsts-task-lib'];
                        if (!libVer) {
                            throw new Error('External vsts-task-lib not defined in externals.json.');
                        }

                        // Copy the lib from the cache.
                        gutil.log('Linking vsts-task-lib ' + libVer);
                        var copySource = path.join(_tempPath, 'npm', 'vsts-task-lib', libVer, 'node_modules', '**');
                        var copyTarget = path.join(targetPath, 'node_modules');
                        shell.mkdir('-p', copyTarget);
                        gulp.src([copySource]).pipe(gulp.dest(copyTarget));
                    }
                }
                return;
            })
            .then(function() {
                done();
            })
            .fail(function(err) {
                done(err);
            })
        });