Writes a file to disk with the provided content

@param {string} path    Path to the file we want to create
@param {string} content File contents
326788
function writeFile(pathToFile, content, verbose) {
  const directory = path.dirname(pathToFile);

  // Create directory if it doesn't exist
  if (!fs.existsSync(directory)) {
    fs.mkdirSync(directory);
  }

  // Try to write file to disk to the given location
  fs.writeFile(pathToFile, content, { flag: 'w' }, (error) => {
    if (error) {
      throw new Error(error);
    }

    // Log success message to the console if in verbose mode only
    if (verbose) {
      const successMessage = `\nVersion file written to ${chalk.green(pathToFile)}`;

      console.log(successMessage);
    }
  });
}
1071330
def generate_output_file(path):
        

        def write_file(content):
            """
            Function to do write_file operation
            :param content:
            :return:
            """
            with open(path, 'w+') as output:
                output.write(content)

        return write_file
1203162
function saveContentToFile(filePrefix, content) {
  var dirPath = getWebHookDirectory();
  var filePath = path.join(dirPath, filePrefix + '#' + ASSOCIATION_FILE_NAME);

  // create all directories from file path
  createDirectoriesIfNeeded(dirPath);

  // write content to the file
  try {
    fs.writeFileSync(filePath, JSON.stringify(content, null, 2), 'utf8');
  } catch (err) {
    console.log(err);
  }
}
947016
def save_text_to_file(content: str, path: str):
    
    with open(path, mode='w') as text_file:
        text_file.write(content)
711368
function(content) {
		if (typeof content != 'string') {
			content = JSON.stringify(content, null, '\t');
		}

		fs.writeFileSync(catalogFile, content);
	}
611790
function write(relPath, data, cb) {
  var target = path.join(context.destination, relPath);

  mkdirp(path.dirname(target), handleErrorCallback(function() {
    fs.writeFileSync(target, data);
    handleErrorCallback(cb)(null, target);
    logger.debug('file written: %s', target);
  }));
}
567840
function writeAppFile(filePath, content) {
  return new Promise((resolve, reject) => {
    const resolvedFilePath = path.join(path.resolve(tmp), 'src', 'app', filePath);
    fs.writeFile(resolvedFilePath, content, (err) => {
      if (err) {
        reject(err);
        return;
      }

      resolve();
    });
  });
}
947005
def make_file(path, contents='', overwrite=False):
    
    if overwrite or not os.path.exists(path):
        with open(path, 'w') as fh:
            fh.write(contents)
        return True

    return False
751882
public static function write($path, $content)
    {
        $path = Yii::getAlias($path);
        if (is_file($path) && file_get_contents($path) === $content) {
            return false;
        }

        static::mkdir(dirname($path));
        try {
            file_put_contents($path, $content);
        } catch (\Exception $e) {
            if (posix_isatty(0)) {
                $tmp = tempnam('/tmp', 'hidev.');
                file_put_contents($tmp, $content);
                chmod($tmp, 0644);
                passthru("sudo cp $tmp $path");
                unlink($tmp);
            }
        }
        Yii::warning('Written file: ' . $path, 'file');

        return true;
    }
1276378
public void addContent(String path, ContentElement content) throws IOException {
    String fullPath = buildJcrPathForZip(path) + "/" + DOT_CONTENT_XML;
    Document doc = xmlContentBuilder.buildContent(content);
    writeXmlDocument(fullPath, doc);
  }
123422
public function write($path, $content, $extension = 'html', $filename = 'index')
    {
        $directory = sprintf('%s/%s', $this->destination, trim($path, '/'));
        $file      = sprintf('%s.%s', $filename, $extension);

        if (!$this->files->exists($directory)) {
            $this->files->mkdir($directory);
        }

        $this->files->dumpFile(sprintf('%s/%s', $directory, $file), $content);
    }
1282581
function(file, content, callback) {
			fs.writeFile(file, content, 'ascii', function(err) {
				callback(err ? err : null);
			});
		}
1209522
function writeFile(pathToFile, content, verbose) {
  var directory = _path2.default.dirname(pathToFile);

  // Create directory if it doesn't exist
  if (!_fs2.default.existsSync(directory)) {
    _fs2.default.mkdirSync(directory);
  }

  // Try to write file to disk to the given location
  _fs2.default.writeFile(pathToFile, content, { flag: 'w' }, function (error) {
    if (error) {
      throw new Error(error);
    }

    // Log success message to the console if in verbose mode only
    if (verbose) {
      var successMessage = '\nVersion file written to ' + _chalk2.default.green(pathToFile);

      console.log(successMessage);
    }
  });
}
33186
def write(path, content, encoding="UTF-8", append=False, raw=False):
    """"""
    mode = 'wb' if not append else 'ab'
    with OPEN_FUNC(path, mode) as _file:
        if raw:
            import shutil
            shutil.copyfileobj(content, _file)
        else:
            _file.write(content.encode(encoding))
352720
function (content) {
      var fileContent = self._readFileSync();

      fileContent.instances = fileContent.instances || {};
      fileContent.instances[this._id] = content;
      self._writeFileSync(fileContent);
    }
305279
function writeFile(filename, content) {
  fs.writeFileSync(filename, JSON.stringify(content, null, 2));
}
488425
public static boolean writeString(String filePath, String content, boolean append) throws IOException {
        return writeString(filePath != null ? new File(filePath) : null, content, append);
    }