<commit_before>/*
 *   Copyright 2014 <NAME> (http://guybedford.com)
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */

exports.HOME = process.env.HOME || process.env.USERPROFILE || process.env.HOMEPATH;

var ui = require('./ui');
var fs = require('graceful-fs');
var path = require('path');
var PackageConfig = require('./config/package');
var LoaderConfig = require('./config/loader');
var mkdirp = require('mkdirp');
var extend = require('./common').extend;
var config = module.exports;
var asp = require('rsvp').denodeify;

// given a package.json file and an override
// calculate the package.json file jspm will see
exports.derivePackageConfig = function(pjson, override) {
  var dpjson = extend({}, pjson);

  // first derive the override
  dpjson.jspm = extend({}, pjson.jspm || {});

  if (override)
    extend(dpjson.jspm, override);

  // then apply the override
  extend(dpjson, dpjson.jspm);

  // add default registry option if dependency override provided
  if (dpjson.jspm.dependencies)
    dpjson.registry = dpjson.registry || 'jspm';

  return dpjson;
}

// package and loader configuration objects that are created
exports.pjson = null;
exports.loader = null;

var loadPromise;
exports.loaded = false;
exports.load = function(prompts) {
  if (loadPromise)
    return loadPromise;

  return loadPromise = Promise.resolve()
  .then(function() {
    if (!process.env.jspmConfigPath)
      return ui.confirm('Package.json file does not exist, create it?', true);
  })
  .then(function() {
    config.pjsonPath = process.env.jspmConfigPath || path.resolve(process.cwd(), 'package.json');

    config.pjson = new PackageConfig(config.pjsonPath);<commit_msg>actually abort package.json creation<commit_after>/*
 *   Copyright 2014 <NAME> (http://guybedford.com)
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */

exports.HOME = process.env.HOME || process.env.USERPROFILE || process.env.HOMEPATH;

var ui = require('./ui');
var fs = require('graceful-fs');
var path = require('path');
var PackageConfig = require('./config/package');
var LoaderConfig = require('./config/loader');
var mkdirp = require('mkdirp');
var extend = require('./common').extend;
var config = module.exports;
var asp = require('rsvp').denodeify;

// given a package.json file and an override
// calculate the package.json file jspm will see
exports.derivePackageConfig = function(pjson, override) {
  var dpjson = extend({}, pjson);

  // first derive the override
  dpjson.jspm = extend({}, pjson.jspm || {});

  if (override)
    extend(dpjson.jspm, override);

  // then apply the override
  extend(dpjson, dpjson.jspm);

  // add default registry option if dependency override provided
  if (dpjson.jspm.dependencies)
    dpjson.registry = dpjson.registry || 'jspm';

  return dpjson;
}

// package and loader configuration objects that are created
exports.pjson = null;
exports.loader = null;

var loadPromise;
exports.loaded = false;
exports.load = function(prompts) {
  if (loadPromise)
    return loadPromise;

  return loadPromise = Promise.resolve()
  .then(function() {
    if (!process.env.jspmConfigPath)
      return ui.confirm('Package.json file does not exist, create it?', true)
      .then(function(create) {
        if (!create)
          throw 'Operation aborted.';
      })
  })
  .then(function() {
    config.pjsonPath = process.env.jspmConfigPath || path.resolve(process.cwd(), 'package.json');

    config.pjson = new PackageConfig(config.pjsonPath);
{'fraction_non_alphanumeric': 0.12121212121212122, 'fraction_numerical': 0.0035390400353904005, 'mean_word_length': 3.7650158061116965, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1144782', 'n_tokens_mistral': 1315, 'n_tokens_neox': 1295, 'n_words': 432}