GithubHelp home page GithubHelp logo

johno / gfc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jonschlinkert/gfc

0.0 3.0 0.0 15 KB

Simple way to initialize a new git repository in an empty directory, add a file and do a first commit (or skip that part in a directory with files). Useful for unit tests and generators.

Home Page: https://github.com/jonschlinkert/gfc

License: MIT License

JavaScript 100.00%

gfc's Introduction

gfc NPM version NPM monthly downloads Linux Build Status Windows Build Status

Simple way to initialize a new git repository in an empty directory, add a file and do a first commit (or skip that part in a directory with files). Useful for unit tests and generators.

Install

Install with npm:

$ npm install --save gfc

Install with yarn:

$ yarn add gfc

Usage

var firstCommit = require('gfc');

// async
firstCommit(cwd[, options], function(err, stdout, stderr) {
  if (err) {
    console.error('exec error: ' + err);
    return;
  }
  console.log('stdout: ' + stdout);
  console.log('stderr: ' + stderr);
});

// sync
firstCommit.sync(cwd[, options]);

Example

var firstCommit = require('gfc');
var dir = 'foo/bar';

firstCommit(dir, function(err) {
  if (err) {
    console.log(err);
  } else {
    console.log('done!');
  }
});

(NOTE: Most of the following examples will show async usage, but for the most part, the sync method works the same way without the callback)

What does this do?

By default, this library will:

  1. create a new git repository
  2. add a temp.txt file
  3. git add .
  4. do a first commit with the message "first commit"

You can disable #2, or customize other behavior via options.

Options

options.contents

Type: string

Default: 'test fixture'

If not disabled, customize the contents of the default file added in step 2.

var options = {contents: 'my custom contents'};

firstCommit('foo/bar', options, function(err) {
  if (err) {
    console.log(err);
  } else {
    console.log('done!');
  }
});

options.file

Type: boolean

Default: undefined

Disable adding the default file in step 2.

var options = {file: false};

firstCommit('foo/bar', options, function(err) {
  if (err) {
    console.log(err);
  } else {
    console.log('done!');
  }
});

options.filename

Type: string

Default: 'temp.txt'

If not disabled, customize the filename of the file added in step 2.

var options = {message: 'my amazing first commit'};

firstCommit('foo/bar', options, function(err) {
  if (err) {
    console.log(err);
  } else {
    console.log('done!');
  }
});

options.message

Type: string

Default: 'first commit'

Customize the first commit message.

var options = {message: 'my amazing first commit'};

firstCommit('foo/bar', options, function(err) {
  if (err) {
    console.log(err);
  } else {
    console.log('done!');
  }
});

options.exec

Type: object

Default: undefined

Options to pass to execSync.

var options = {
  message: 'my amazing first commit',
  exec: {
    timeout: 3000,
    killSignal: 'SIGTERM'
  }
};

firstCommit.sync('foo/bar', options);

options.skipCommit

Type: boolean

Default: false

Initialize the repo and create the file but don't git commit or git add ..

var options = { skipCommit: true };

firstCommit.sync('foo/bar', options);

About

Related projects

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Please read the contributing guide for advice on opening issues, pull requests, and coding standards.

Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test

Author

Jon Schlinkert

License

Copyright © 2017, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.5.0, on April 19, 2017.

gfc's People

Contributors

johno avatar jonschlinkert avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.