Loads mutations from a folder inside the `enclosingFolder` called "mutations".
@param {String} enclosingFolder
@return {JSON} a map of the mutation name to the mutation's export.
438002
function loadMutations(enclosingFolder) {
  const here = jetpack.cwd(pathToMutations(enclosingFolder));

  const pkg = here.read(PACKAGE_JSON, "json");
  errorIf(
    !pkg,
    `There doesn't seem to be a package.json file. 
Did you create one at the enclosing folder? 
FYI: installMutations creates one for you if you don't have one. `
  );

  const node_modules_path = here.dir(NODE_MODULES).cwd();

  return new Promise((resolve, reject) => {
    // Load in mutations from dependencies
    const mutations = loadMutationsFromDependencies(
      pkg.dependencies,
      node_modules_path
    );
    resolve(mutations);
  });
}
170442
function load_shims_sync(paths, browser) {
    // identify if our file should be replaced per the browser field
    // original filename|id -> replacement
    var shims = Object.create(null);
    var cur_path;

    while (cur_path = paths.shift()) {
        var pkg_path = path.join(cur_path, 'package.json');

        try {
            var data = fs.readFileSync(pkg_path, 'utf8');
            find_shims_in_package(data, cur_path, shims, browser);
            return shims;
        }
        catch (err) {
            // ignore paths we can't open
            // avoids an exists check
            if (err.code === 'ENOENT') {
                continue;
            }

            throw err;
        }
    }
    return shims;
}
55023
function _collapseTree(node: TreeNode, depth: number): TreeNode {
  // Node is a folder.
  if (node.type === "directory") {
    if (!Array.isArray(node.contents)) {
      console.log(`Expected array at: ${node.path}`);
    }

    // Node is not a root/domain node, and only contains 1 item.
    if (depth > 1 && node.contents.length === 1) {
      const next = node.contents[0];
      // Do not collapse if the next node is a leaf node.
      if (next.type === "directory") {
        if (!Array.isArray(next.contents)) {
          console.log(
            `Expected array at: ${next.name} -- ${
              node.name
            } -- ${JSON.stringify(next.contents)}`
          );
        }
        const name = `${node.name}/${next.name}`;
        const nextNode = createDirectoryNode(name, next.path, next.contents);
        return _collapseTree(nextNode, depth + 1);
      }
    }

    // Map the contents.
    return createDirectoryNode(
      node.name,
      node.path,
      node.contents.map(next => _collapseTree(next, depth + 1))
    );
  }

  // Node is a leaf, not a folder, do not modify it.
  return node;
}
1330094
function mapByDepth(rootPackage) {
    var depth = 0
      , allDeps = {}
      , superDepsList = {}
      ;

    function traverseDeps(childPackage) {
      depth += 1;

      childPackage.dependencyTree = childPackage.dependencyTree || {};
      Object.keys(childPackage.dependencyTree).forEach(function (depName) {
        var childDeps = (childPackage.dependencyTree[depName] || {}) || {}
          ;

        if (superDepsList[depName]) {
          // a dependency can't (meaning shouldn't) have a path in which it depends on itself
          // this kind of resolution isn't as important as it once was
          // since the modules can be loaded out-of-order
          return;
        }

        superDepsList[depName] = true;

        allDeps[depth] = allDeps[depth] || [];
        allDeps[depth].push(depName);

        if (childDeps) {
          traverseDeps(childDeps);
        }

        superDepsList[depName] = false;
      });

      depth -= 1;
    }

    traverseDeps(rootPackage);

    return allDeps;
  }
857134
async function makeDocumentableObject(folder) {
  const fullPath = path.join(REACT_MD_JS, folder);
  const contents = await readFile(path.join(fullPath, 'index.js'), 'UTF-8');

  const components = contents.split(/\r?\n/).reduce((exports, line) => {
    // go line-by-line in the src/js/SECTION/index.js file to get a list of the exported
    // components in this section
    if (line.match(/export/)) {
      const component = line.replace(/export (default |{ )?(\w+).*/, '$2');
      if (exports.indexOf(component) === -1 && DEPRECATED.indexOf(component) === -1 && component.indexOf('FakeInked') === -1) {
        exports.push(component);
      }
    }

    return exports;
  }, []);

  return { folder, components, fullPath };
}
764764
function pluginFolder () {
  const path = sketchtoolExec('show plugins');
  invariant(path, 'Plugin folder not found!');
  invariant(fs.existsSync(path), `Plugin folder does not exist at ${path}!`);
  return path;
}
269056
function loadConfigFile(configInfo) {
    const { filePath } = configInfo;
    let config;

    switch (path.extname(filePath)) {
        case ".js":
            config = loadJSConfigFile(filePath);
            if (configInfo.configName) {
                config = config.configs[configInfo.configName];
                if (!config) {
                    throw configMissingError(configInfo.configFullName);
                }
            }
            break;

        case ".json":
            if (path.basename(filePath) === "package.json") {
                config = loadPackageJSONConfigFile(filePath);
                if (config === null) {
                    return null;
                }
            } else {
                config = loadJSONConfigFile(filePath);
            }
            break;

        case ".yaml":
        case ".yml":
            config = loadYAMLConfigFile(filePath);
            break;

        default:
            config = loadLegacyConfigFile(filePath);
    }

    return ConfigOps.merge(ConfigOps.createEmptyConfig(), config);
}
892172
function visitPackageJSON(folderPath)
{
  let files = fs.readdirSync(folderPath);
  for (var i in files) {
    let name = files[i];
    let filePath = path.join(folderPath, files[i]);
    if(fs.statSync(filePath).isDirectory()) {
      visitPackageJSON(filePath);
    } else {
      if (name === 'package.json') {
        try {
          patchPackageJSON_preNodeGyp_modulePath(filePath);
        } catch (e) {
          console.warn(
            'Failed to patch the file : "' +
            filePath +
            '". The following error was thrown: ' +
            JSON.stringify(e)
          );
        }
      }
    }
  }
}
136380
public static function fromJSON( $json, $compiledFolder = null )
	{
		$store = json_decode( $json, true );

		if ( json_last_error() !== JSON_ERROR_NONE )
		{
			$error = XBRL::json_last_error_msg();
			XBRL_Log::getInstance()->err( "$error" );
			return false;
		}

		// Check to see if there is a valid base taxonomy reference $store
		// If there is, this is an extension taxonomy so load it as one.
		if ( isset( $store['baseTaxonomy'] ) && $store['baseTaxonomy'] )
		{
			return XBRL::fromExtensionTaxonomy( $store, $compiledFolder );
		}

		$context = XBRL_Global::getInstance();

		$context->labels				 =& $store['context']['labels'];
		$context->labelLinkRoleRefs		 =& $store['context']['labelLinkRoleRefs'];
		$context->labelRoleRefs			 =& $store['context']['labelRoleRefs'];

		if ( ! empty( $store['context']['calculationRoleRefs'] ) )
		{
			$context->calculationRoleRefs	 =& $store['context']['calculationRoleRefs'];
		}
		if ( ! empty( $store['context']['generalSpecialRoleRefs'] ) )
		{
			$context->generalSpecialRoleRefs =& $store['context']['generalSpecialRoleRefs'];
		}
		if ( ! empty( $store['context']['presentationRoleRefs'] ) )
		{
			$context->presentationRoleRefs	 =& $store['context']['presentationRoleRefs'];
		}
		if ( ! empty( $store['context']['essenceAlias'] ) )
		{
			$context->essenceAlias			 =& $store['context']['essenceAlias'];
		}
		if ( ! empty( $store['context']['requireElements'] ) )
		{
			$context->requireElements		 =& $store['context']['requireElements'];
		}
		if ( ! empty( $store['context']['nonDimensionalRoleRefs'] ) )
		{
			$context->nonDimensionalRoleRefs =& $store['context']['nonDimensionalRoleRefs'];
		}
		if ( ! empty( $store['context']['primaryItems'] ) )
		{
			$context->setPrimaryItemsCache( $store['context']['primaryItems'] );
		}
		if ( ! empty( $store['context']['dimensionDefaults'] ) )
		{
			$context->dimensionDefaults =& $store['context']['dimensionDefaults'];
		}
		if ( ! empty( $store['context']['formulaNames'] ) )
		{
			$context->formulaNames =& $store['context']['formulaNames'];
		}
		if ( ! empty( $store['validTaxonomySet'] ) )
		{
			$context->validTaxonomySet = $store['validTaxonomySet'];
		}
		if ( ! empty( $store['isExtensionTaxonomy'] ) )
		{
			if ( filter_var( $store['isExtensionTaxonomy'], FILTER_VALIDATE_BOOLEAN ) )
			{
				$context->setIsExtensionTaxonomy();
			}
		}

		$instance = null;

		foreach ( $store['schemas'] as $namespace => $data )
		{
			$classname = XBRL::class_from_namespace( $namespace );

			/**
			 * @var XBRL $xbrl
			 */
			$xbrl = new $classname();
			$xbrl->context =& $context;
			$xbrl->fromStore( $data );
			$xbrl->context->importedSchemas[ $namespace ] = $xbrl;
			$xbrl->context->schemaFileToNamespace[ $xbrl->getSchemaLocation() ] = $namespace;
			$xbrl->context->schemaFileToNamespace[ $xbrl->getTaxonomyXSD() ] = $namespace;

			if ( $namespace === $store['mainNamespace'] ) $instance = $xbrl;
		}

		XBRL::fixupForeignDefinitionsFromStore( $store['schemas'] );

		if ( isset( $store['context']['types'] ) )
		{
			// $context->types->fromArray( $store['context']['types'] );
			$context->types->mergeTypes( $store['context']['types'] );
		}

		return $instance;
	}
844779
function() {
    var container = document.createElement('mutation');
    container.setAttribute('name', this.getProcedureCall());
    for (var i = 0; i < this.arguments_.length; i++) {
      var parameter = document.createElement('arg');
      parameter.setAttribute('name', this.arguments_[i]);
      container.appendChild(parameter);
    }
    return container;
  }
1318211
def container_new_folder(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/newFolder' % object_id, input_params, always_retry=always_retry, **kwargs)
587870
function instance_mutations () {
        var _parseArguments = parseArguments$2(arguments),
            options = _parseArguments.options,
            mutations = _parseArguments.mutations;

        return Object.keys(mutations).reduce(function (instanceMutations, name) {
            instanceMutations[name] = findInstanceThen(options, mutations[name]);

            return instanceMutations;
        }, {});
    }
477371
function loadLocalConfigUnmodified(configPath) {
	try {
		return JSON.parse(fs.readFileSync(configPath, 'utf-8'));
	} catch (error) {
		if (error.code !== 'ENOENT') {
			throw error;
		}
	}
}
1150702
function loadNodeBuilder(data) {
	return new Promise(function(resolve, reject) {
		var graph = data.graph;
		var loader = data.loader;

		var promises = keys(graph).map(function(nodeName) {
			var node = graph[nodeName];

			// pluginBuilder | extensionBuilder is a module identifier that
			// should be loaded to replace the node's source during the build
			var nodeBuilder =
				node.value && (node.value.pluginBuilder || node.value.extensionBuilder);

			// nothing to do in this case, return right away
			if (!nodeBuilder) return;

			return loader
				.normalize(nodeBuilder)
				.then(locate)
				.then(_fetch)
				.then(makeReplace(node));
		});

		function locate(name) {
			return Promise.all([name, loader.locate({ name: name, metadata: {} })]);
		}

		// [ name, address ]
		function _fetch(data) {
			return Promise.all([
				data[1],
				loader.fetch({ name: data[0], address: data[1], metadata: {} })
			]);
		}

		function makeReplace(node) {
			// [ address, load ]
			return function replace(data) {
				node.load = assign(node.load, {
					address: data[0],
					source: data[1],
					metadata: {}
				});
			};
		}

		Promise.all(promises)
			.then(function() {
				resolve(graph);
			})
			.catch(reject);
	});
}
60662
function concatPackage (pack, outDir, minified) {
  if (_.contains(concatedPkgs, path.basename(pack))) return;

  var bowerFile = 'bower.json';

  if (! fs.existsSync(path.join(pack, bowerFile)))
    bowerFile = '.bower.json';

  var regularJSON = JSON.parse(
    fs.readFileSync(path.join(pack, bowerFile))
  );
  var bowerJSON = json.normalize(regularJSON);
  var deps = bowerJSON.dependencies || {};
  var mains = bowerJSON.main || [];

  concatedPkgs.push(path.basename(pack));

  _.each(Object.keys(deps), function (pkg, i, l) {
    var components = pack.split(path.sep);
    var pkgpath = components.slice(0, -1).join(path.sep);

    concatPackage(path.join(pkgpath, pkg), outDir, minified);
  });

  debug('concatenating package ' + path.basename(pack) + '...');

  var files = constructFileList(pack, mains, minified);
  var concatJS = '', concatCSS = '';

  _.each(files, function (filepath, i, l) {
    var contents = fs.readFileSync(filepath) + '\n';
    var ext = filepath.split('.')[filepath.split('.').length - 1];

    if (ext === 'js' || ext === 'css')
      debug('including file ' + filepath + '...');

    if (ext === 'js')
      concatJS += contents;
    else if (ext === 'css')
      concatCSS += contents;
  });

  if (concatJS !== '' || concatCSS !== '')
    debug('writing files...');

  if (concatJS !== '')
    fs.appendFileSync(path.join(outDir, 'build.js'), concatJS);

  if (concatCSS !== '')
    fs.appendFileSync(path.join(outDir, 'build.css'), concatCSS);
}
1324779
function createNativeSolcFolder()
{
	return new Promise((resolve, reject) => {
		fs.mkdir(nativeCompilerFolder, function (err) {
			if ((!err) || err.code == 'EEXIST') {
				resolve();
			}
			else {
				reject(err);
			}
		});
	});
}
326843
function load(file) {
    if (path.extname(file) === ".yaml" || path.extname(file) === ".yml") {
      return yaml.safeLoad(fs.readFileSync(file));

    } else if (path.extname(file) === ".json") {
      var r = JSON.parse(fs.readFileSync(file));
      return r;

    } else if (path.extname(file) === ".js") {
      var obj = require(file);
      
      if (typeof(obj) !== "object") {
        throw {error: "needs to export object, not "+typeof(obj), file: file};

      } else {
        return clone(obj);
      }
    } else {
      throw {error: path+" has invalid extension: "+path.extname(file)};
    }
  }