Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clonerepository #8

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/fast-forward-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,24 @@ class FastForwardView
)
@element.appendChild(@button)

# Create button element
@button2 = document.createElement('button')
@button2.textContent = "Clone Repo"
@button2.classList.add('btn-primary')
@button2.classList.add('btn')

# Event listening for button. Emits event to the FastForward module.
@button2.addEventListener('click', () =>
@emitter.emit('install-button-event')
)
@element.appendChild(@button2)
# Returns an object that can be retrieved when package is activated
serialize: ->

# Tear down any state and detach
destroy: ->
@button.removeEventListener('click', 0)
@button2.removeEventListener('click', 0)
@element.remove()

getElement: ->
Expand Down
72 changes: 72 additions & 0 deletions lib/fast-forward.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
FastForwardView = require './fast-forward-view'
{CompositeDisposable, Emitter} = require 'atom'
git = require 'simple-git'
fs = require 'fs'
cmd = require 'node-cmd'

project_directory = process.env['USERPROFILE'] + "\\Documents\\MyCodingAndCommunityProjects"

plugin_path = atom.project.getPaths()[0]

#have these entered in the plugin
REPO = 'https://github.com/rmccue/test-repository'
name = 'first project'
base_project_path = project_directory + "\\My_first_project"
project_path = base_project_path

count = 0


handler = (err) ->
if err != null
console.log err

fs.mkdir(project_directory, handler)

module.exports = FastForward =
fastForwardView: null
Expand All @@ -20,8 +42,10 @@ module.exports = FastForward =

# Register command that toggles this view
@subscriptions.add(atom.commands.add('atom-workspace', {'fast-forward:toggle': () => @toggle()}))
@subscriptions.add(atom.commands.add('atom-workspace', {'fast-forward:installdependencies': () => @installDependencies()}))

@emitter.on 'toggle-button-event', => @toggle()
@emitter.on 'install-button-event', => @installDependencies()

deactivate: ->
@modalPanel.destroy()
Expand All @@ -38,3 +62,51 @@ module.exports = FastForward =
@modalPanel.hide()
else
@modalPanel.show()

#brads button
installDependencies: ->

#clones the repo inside of the project path
clone = () ->
git().clone REPO, project_path, errorlog

#handler for just printing out errors for simplegit which just prints out the error
errorlog = (err, idk) ->
if err != null
console.log err

#handler for chekcing the status for the directory
projectStatHandler = (err, stat) ->

#if the directory exists then create the directory and then the callback function clones the repo
if err && err.code == "ENOENT"
fs.mkdir(project_path, clone)
console.log "made the Directory at #{ project_path }"

#otherwise add one to project path and then check the path again
else
console.log('Directory already exists.')
count = count + 1
project_path = base_project_path + "(" + count + ")"

projectCheck()

#calls fs.stat which checks the status of a directory
projectCheck = () ->
fs.stat project_path, projectStatHandler

#the button code to find the correct project directory and clone it from github
projectCheck()
count = 0

#handler to print out stuff from cmd
cmdHandler = (err, data, stderr) ->
console.log err
console.log data
console.log stderr

#install the dependencies from the newly cloned project
cmd.get(
'
dir
', cmdHandler)
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
"main": "./lib/fast-forward",
"version": "0.0.0",
"description": "A short description of your package",
"keywords": [
],
"keywords": [],
"repository": "https://github.com/atom/fast-forward",
"license": "MIT",
"engines": {
"atom": ">=1.0.0 <2.0.0"
},
"dependencies": {
}
"dependencies": {}
}