Giter Club home page Giter Club logo

node-svn-spawn's Introduction

svn-spawn

npm npm Travis npm

Easy way to access svn repository with node.js.

Features

  • Easy to use
  • Fast way to add local changes
  • Query svn infomation as array or object
  • Common svn commands are all supported

Usage

Create a svn client instance

var Client = require('svn-spawn');
var client = new Client({
    cwd: '/path to your svn working directory',
    username: 'username', // optional if authentication not required or is already saved
    password: 'password', // optional if authentication not required or is already saved
    noAuthCache: true, // optional, if true, username does not become the logged in user on the machine
});

svn update

client.update(function(err, data) {
    console.log('updated');
});

svn info

client.getInfo(function(err, data) {
    console.log('Repository url is %s', data.url);
});

Make some changes and commit all

client.addLocal(function(err, data) {
    console.log('all local changes has been added for commit');

    client.commit('commit message here', function(err, data) {
        console.log('local changes has been committed!');
    });
});

Single file

client.add('relative/path/to/file', function(err, data) {
    client.commit(['commit message here', 'relative/path/to/file'], function(err, data) {
        console.log('committed one file!');
    });
});

Run any svn command

client.cmd(['subcommand', '--option1=xx', '--option2=xx', 'arg1', 'arg2'], function(err, data) {
    console.log('subcommand done');
});

Result Object

getXXX methods will return parsed data as object.

getInfo result example:

{
  "$": {
    "path": ".",
    "revision": "1",
    "kind": "dir"
  },
  "url": "file:///home/dong/projects/node-packages/node-svn-spawn/test/tmp/repo",
  "repository": {
    "root": "file:///home/dong/projects/node-packages/node-svn-spawn/test/tmp/repo",
    "uuid": "302eb8ee-a81a-4432-8477-1ad8fe3a9a1e"
  },
  "wc-info": {
    "wcroot-abspath": "/home/dong/projects/node-packages/node-svn-spawn/test/tmp/copy",
    "schedule": "normal",
    "depth": "infinity"
  },
  "commit": {
    "$": {
      "revision": "1"
    },
    "author": "dong",
    "date": "2013-11-08T02:07:25.884985Z"
  }
}

getLog result example:

[
    {
      "$": {
        "revision": "1"
      },
      "author": "dong",
      "date": "2013-11-08T02:10:37.656902Z",
      "msg": "init repo"
    },
    ...
]

getStatus result example:

[
  {
    "$": {
      "path": "a.txt"
    },
    "wc-status": {
      "$": {
        "props": "none",
        "item": "modified",
        "revision": "1"
      },
      "commit": {
        "$": {
          "revision": "1"
        },
        "author": "dong",
        "date": "2013-11-08T02:17:20.390152Z"
      }
    }
  }
]

Requirements

You need to have the svn command installed.

Installation

npm install svn-spawn

node-svn-spawn's People

Contributors

anatdagan avatar ddliu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-svn-spawn's Issues

addlocal error

hi, I commit [global-201608121735.png,global-201608121735.svg,global-201608121735-svg.png] all three files ,but 'global-201608121735.png' commit fail ,why?

image

but I use client.cmd(['add','dir','--force'], function (err, data) {} no this problem

what is the fucntion getlog callback Character encoding?

hello.
i use the getlog callback for me is not utf8? i try to change gbk or gbk2312 but it still a Garbled for me, how to do the function callback's data utf8 for me?
by the way, i try use to tool from iconv-lite to do it,but invalid

Doesn't work on Windows

Getting this exception:

{ [Error: spawn ENOENT] code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn' }

Adding multiple files inside a folder

Hi!

First of all, thanks for this module it has been quite simple to understand it. However, I ran into a small issue (hopefully it is small :) )

I am trying to implement a scheduled commit (every day) for all log files inside a folder. My problem is that I first have to add all files inside the folder and then commit that folder alone. I tried using the add function and adding /* at the end of the file path as shown below:

client.add('LoggingServer/testLogs/*', function(err, data) {

        client.commit(['This is an automatic commit for the log files', 'LoggingServer/testLogs'], function(err, data) {
                console.log('Log files committed!');
        });
});

Unfortunately, that does not work and I get this error:

svn: warning: W155010: '/Users/silvia/WebstormProjects/miracle/src/LoggingServer/testLogs/' not found
svn: E200009: Could not add all targets because some targets don't exist
svn: E200009: Illegal target for the requested operation
{ [Error: svn: warning: W155010: '/Users/silvia/WebstormProjects/miracle/src/LoggingServer/testLogs/
' not found
svn: E200009: Could not add all targets because some targets don't exist
svn: E200009: Illegal target for the requested operation
] code: 1, output: '' }

I also checked the addLocal function but that is not an option because I do not want ALL local changes to be added because I only want the files inside that specific folder to be committed periodically.

Thanks a lot in advance. Hopefully someone can help me with this issue.

Support multiple files

Hi,

if there is support, it would be nice to add some examples to make it clear.
Otherwise, adding support would be great.

Unable to connect to a repository at URL

{ Error: svn: E210007: Unable to connect to a repository at URL '..../ECR_ICF_V02R01_20200105/FRONT'
svn: E210007: �޷�Э����֤����

at ChildProcess.<anonymous> (D:\coding\ECR_ICF\online-pc\node_modules\easy-spawn\index.js:88:25)    at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:915:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5) code: 1, output: '��

������ '.':\r\n' } undefined

cannot ignore stdio

var Client = require('svn-spawn');
var client = new Client({
    cwd: '/path to your svn working directory',
    username: 'username', // optional if authentication not required or is already saved
    password: 'password', // optional if authentication not required or is already saved
    noAuthCache: true, // optional, if true, username does not become the logged in user on the machine
});

Like this, when the username or password is wrong. the server will open a stdio to wait input username and password. This is can't ignore the stdio.
Could you support this feature?

duplicated results for svn ls

The below code will return duplicated result.

      svn.cmd(['ls', baseUrl], function (err, data) {
        if (err) {
          throw err;
        }
        var lines = data.split("\n"),
          i;
        for (i = 0; i < lines.length; i++) {
          console.log(lines[i]);
        }
      });

The below does not return duplicates:

      exec('svn ls ' + baseUrl, function (error, stdout, stderr) {
        var lines = stdout.split("\n"),
          i;
        for (i = 0; i < lines.length; i++) {
          console.log(lines[i]);
        }
      });

Unable to get the data from svn url

Hi ,

I am new to both svn and nodejs. I was basically looking for a javascript wrapper for SVN access and then I stumbled upon your node module. Your commands looked very simple to use so I decided to try out. So I decided to checkout the code from here https://code.google.com/p/support/source/checkout , but was unable to to so as I got the below error:

the code used:

var Client = require('svn-spawn');
var client = new Client({
cwd: 'http://support.googlecode.com/svn/trunk/'
});

client.cmd(['checkout'], function(err, data) {
if(!err){
console.log('subcommand done' + data);
}else{
console.log('the erro is '+ err);
}
});

And the error I got is:

the erro is Error: spawn ENOENT
chdir(): No such file or directory
the erro is Error: chdir(): No such file or directory

What I am doing wrong?

Not working on Debian 7.11 on a Beagle Bone Black

I'm just running code I basically took right of your page. The client object won't instantiate. The actual error thrown is on the console.log statement near the bottom. Any help is greatly appreciated, or if nothing else just a heads up . . . I don't know if you guys are interested in testing on Debian on the Beagle Bone architecture.

Cheers.

Here's the error:
2017-09-16T22:49:28.588Z - error: uncaughtException: Cannot read property 'url' of undefined date=Sat Sep 16 2017 22:49:28 GMT+0000 (UTC)

// CODE:
var SvnClient = require('svn-spawn');
client = new SvnClient({
cwd: 'https://calmicrosystems.svn.cloudforge.com/mercury_1up_tester/trunk/',
username: 'xxx',
password: 'xxx'
});
// note: i 'xxx'-d out my legitimate credentials. I'm logged in on the command line with the same credentials, everything working fine.

client.getInfo(function(err, data) {
console.log('svn info. repository url is %s', data.url);
});

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.