# All files / dist/systemTools doctor.js

23.4% Statements 11/47
0% Branches 0/19
0% Functions 0/8
20.45% Lines 9/44

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    704x

    4x

    4x

    4x

    4x

    4x

    4x

    4x
    4x
     var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.fixPackageObject=exports.fixPackageJson=void 0;var _chalk=_interopRequireDefault(require("chalk"));
    var _fileutils=require("./fileutils");
    var _constants=require("../constants");
    var _common=require("../common");

    var getSortedObject=function getSortedObject(obj){
    if(obj!==null&&typeof obj==='object'&&!Array.isArray(obj)){
    var keys=Object.keys(obj).sort();
    var newObj={};
    var addedKeys={};
    keys.forEach(function(v){
    if(!addedKeys[v]){
    newObj[v]=obj[v];
    addedKeys[v]=true;
    }else{

    }
    });
    return newObj;
    }if(Array.isArray(obj)){
    return obj.sort();
    }
    return obj;
    };

    var checkForDuplicates=function checkForDuplicates(arr){
    var dupCheck={};
    arr.forEach(function(v){
    if(v){
    for(var k in v){
    if(dupCheck[k]){
    (0,_common.logWarning)("Key "+_chalk.default.white(k)+" is duplicated in your package.json");
    }
    dupCheck[k]=true;
    }
    }
    });
    };

    var fixPackageJson=function fixPackageJson(c,pkgPath){return new Promise(function(resolve,reject){
    var pth=pkgPath||c.paths.project.package;
    var pp=(0,_fileutils.readObjectSync)(pth);
    var output=fixPackageObject(pp);
    (0,_fileutils.writeObjectSync)(pth,output,4);
    resolve();
    });};exports.fixPackageJson=fixPackageJson;

    var fixPackageObject=function fixPackageObject(pp){
    var output={};
    var usedKeys={};
    _constants.PACKAGE_JSON_FILEDS.forEach(function(v){
    if(pp[v]!==null){
    output[v]=getSortedObject(pp[v]);
    usedKeys[v]=true;
    }
    });
    for(var k in pp){
    if(!usedKeys[k]){
    output[k]=pp[k];
    }
    }
    checkForDuplicates([pp.dependencies,pp.devDependencies]);

    return output;
    };exports.fixPackageObject=fixPackageObject;var _default=

    {
    fixPackageJson:fixPackageJson,fixPackageObject:fixPackageObject};exports.default=_default;
    //# sourceMappingURL=doctor.js.map