Giter Club home page Giter Club logo

Comments (7)

Skycoder42 avatar Skycoder42 commented on August 11, 2024

Hi. What exactly is your problem? Maybe you can show some error logs. Running the tool inside of a subfolder is already supported. All you need to do is specify the directory to run the command in:

# simply cd into your directory before running the script
cd my/subdir
dart run dart_pre_commit

# or install it globally...
dart pub global activate dart_pre_commit
# ... and use the `-d` switch
dart pub global run dart_pre_commit -d my/subdir

from dart_pre_commit.

taosif7-dreamorbit avatar taosif7-dreamorbit commented on August 11, 2024

Hi, So actually I'm using DartPreCommit via git_hooks package, so basically I'm running it with dart via DartPreCommit.run();

So this runs from root of my git folder, hence not able to find the pubspec.yaml file which is inside a subfolder.

Only if there was a parameter to pass to DartPreCommit.run() to specify the project subfolder, it would find the pubspec.yaml file

See what I'm doing:

void main(List<String> arguments) {
  Map<Git, UserBackFun> params = {
    Git.preCommit: _preCommit,
  };
  GitHooks.call(arguments, params);
}

Future<bool> _preCommit() async {
  final result = await DartPreCommit.run();
  return result.isSuccess;
}

from dart_pre_commit.

Skycoder42 avatar Skycoder42 commented on August 11, 2024

I am not sure if it is possible to use the git_hooks package without a top level pubspec.yaml. However, if we assume it does work, you can easily set the directory to be scanned by changing the current working directory of the script:

Future<bool> _preCommit() async {
  Directory.current = 'my/subdir';
  final result = await DartPreCommit.run();
  return result.isSuccess;
}

from dart_pre_commit.

Skycoder42 avatar Skycoder42 commented on August 11, 2024

Did this fix your problem?

from dart_pre_commit.

taosif7-dreamorbit avatar taosif7-dreamorbit commented on August 11, 2024

Did this fix your problem?

Hi, yes this worked perfectly for me.
I think we should include this piece of information in the readme, if you allow me I'd like to add

from dart_pre_commit.

Skycoder42 avatar Skycoder42 commented on August 11, 2024

Yes, I am always happy to accepts PRs, feel free to do so

from dart_pre_commit.

taosif7-dreamorbit avatar taosif7-dreamorbit commented on August 11, 2024

Thankyou, I'll send PR.

from dart_pre_commit.

Related Issues (20)

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.