<commit_before>// Copyright 2015, EMC, Inc.

'use strict';

var di = require('di');
var express = require('express');
var path = require('path');

module.exports = skuPackServiceFactory;
di.annotate(skuPackServiceFactory, new di.Provide('Http.Services.SkuPack'));
di.annotate(skuPackServiceFactory,
    new di.Inject(
        '_',
        'Services.Waterline',
        'Logger',
        'FileLoader',
        'Templates',
        'Profiles',
        'Promise',
        'fs',
        'rimraf',
        'Assert',
        'Http.Services.Api.Workflows',
        'Constants',
        'Services.Environment'
    )
);
function skuPackServiceFactory(
    _,
    waterline,
    Logger,
    FileLoader,
    Templates,
    Profiles,
    Promise,
    nodeFs,
    rimraf,
    assert,
    workflowApiService,
    Constants,
    Env
) {
    var logger = Logger.initialize(skuPackServiceFactory);
    var fs = Promise.promisifyAll(nodeFs);
    var rimrafAsync = Promise.promisify(rimraf);

    function SkuPackService() {
        this.loader = new FileLoader();
        this.confRoot = '';
        this.skuHandlers = {};
    }

    /**
     * Given a nodeId, return the prioritized scope order
     * @param  {string}     nodeId
     */
     SkuPackService.prototype.setupScope = function(nodeId) {
        var defaultScope = [ Constants.Scope.Global ];
        if(!nodeId)  {
            return Promise.resolve(defaultScope);
        }
        return waterline.nodes.needByIdentifier(nodeId)
            .then(function(node) {
                if( _.has(node, 'sku')) {
                    defaultScope.unshift(node.sku);
                }
                return defaultScope;
            });
    };

    /**
     * Implement an Express static file handler
     * @param  {Object}     req
     * @param  {Object}     res
     * @param  {Function}   next
     */
    SkuPackService.prototype.static = function(req, res, next) {
        var self = this;
        if(res.locals.identifier !== undefined) {<commit_msg>Fix null check for node.sku in sku service setupScope<commit_after>// Copyright 2015, EMC, Inc.

'use strict';

var di = require('di');
var express = require('express');
var path = require('path');

module.exports = skuPackServiceFactory;
di.annotate(skuPackServiceFactory, new di.Provide('Http.Services.SkuPack'));
di.annotate(skuPackServiceFactory,
    new di.Inject(
        '_',
        'Services.Waterline',
        'Logger',
        'FileLoader',
        'Templates',
        'Profiles',
        'Promise',
        'fs',
        'rimraf',
        'Assert',
        'Http.Services.Api.Workflows',
        'Constants',
        'Services.Environment'
    )
);
function skuPackServiceFactory(
    _,
    waterline,
    Logger,
    FileLoader,
    Templates,
    Profiles,
    Promise,
    nodeFs,
    rimraf,
    assert,
    workflowApiService,
    Constants,
    Env
) {
    var logger = Logger.initialize(skuPackServiceFactory);
    var fs = Promise.promisifyAll(nodeFs);
    var rimrafAsync = Promise.promisify(rimraf);

    function SkuPackService() {
        this.loader = new FileLoader();
        this.confRoot = '';
        this.skuHandlers = {};
    }

    /**
     * Given a nodeId, return the prioritized scope order
     * @param  {string}     nodeId
     */
     SkuPackService.prototype.setupScope = function(nodeId) {
        var defaultScope = [ Constants.Scope.Global ];
        if(!nodeId)  {
            return Promise.resolve(defaultScope);
        }
        return waterline.nodes.needByIdentifier(nodeId)
            .then(function(node) {
                if (node.sku) {
                    defaultScope.unshift(node.sku);
                }
                return defaultScope;
            });
    };

    /**
     * Implement an Express static file handler
     * @param  {Object}     req
     * @param  {Object}     res
     * @param  {Function}   next
     */
    SkuPackService.prototype.static = function(req, res, next) {
        var self = this;
        if(res.locals.identifier !== undefined) {
{'fraction_non_alphanumeric': 0.11928429423459244, 'fraction_numerical': 0.0019880715705765406, 'mean_word_length': 2.0748663101604277, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2114436', 'n_tokens_mistral': 1220, 'n_tokens_neox': 1191, 'n_words': 243}