Git Product home page Git Product logo

Comments (13)

tionis avatar tionis commented on July 21, 2024 1

Not really, when I find time I will go over the current sh.janet in detail. I find the namespace currently a bit unorganized

from spork.

tionis avatar tionis commented on July 21, 2024

This is probably due to git adding the CR byte on checkout, I'd like to test this, but don't have a working jpm setup on my windows machine.

from spork.

sogaiu avatar sogaiu commented on July 21, 2024

In a different repository I had added this: https://github.com/sogaiu/judge-gen/blob/master/.gitattributes

Does that seem like the kind of thing you had in mind for testing?

from spork.

tionis avatar tionis commented on July 21, 2024

To be honest, I not really sure. I would have to experiment with it myself. But if that works and doesn't break anything else ok the project, it should be fine I think?
Maybe this should be applied to all static test files then?

from spork.

sogaiu avatar sogaiu commented on July 21, 2024

@tionis

I looked into the situation a bit more.

If test.file doesn't have any line ending characters, the test seems to work fine.

If test.file ends with a newline character, the test fails and it looks like test2.file has both a carriage return and a newline character at the end.

The :w in the file/open of make-new-file may be a factor:

spork/spork/sh.janet

Lines 95 to 104 in 63f656e

(defn make-new-file
"Create and open a file, creating all the directories leading to the file if
they do not exist, and return it. By default, open as a writable file (mode is `:w`)."
[file-path &opt mode]
(default mode :w)
(let [parent-path (path/dirname file-path)]
(when (and (not (exists? file-path))
(not (exists? parent-path)))
(create-dirs parent-path)))
(file/open file-path :w))

Chaging the mode to :wb made the test pass.


On a side note, it doesn't look like make-new-file's optional parameter mode is used anywhere.

from spork.

tionis avatar tionis commented on July 21, 2024

I see, I completely forgot about the existence of the binary flag for file/open

from spork.

sogaiu avatar sogaiu commented on July 21, 2024

@tionis

Regarding sh/make-new-file and the mode argument, I filed #98.

Perhaps a straight-forward fix would be to make file/open's second argument mode.

So:

(file/open file-path :w)

would become:

(file/open file-path mode)

If that seems appropriate, perhaps the line in sh/copy-file:

(with [dst (make-new-file dst-path)]

can specify a different mode, say :wb, to address this issue.

How does that seem?

from spork.

tionis avatar tionis commented on July 21, 2024

Perhaps an additional keyword argument :mode for the file creating functions would be useful instead.

from spork.

sogaiu avatar sogaiu commented on July 21, 2024

By "keyword argument", do you mean this sort of thing? https://janet-lang.org/docs/functions.html#Keyword-style-arguments

from spork.

tionis avatar tionis commented on July 21, 2024

Yes, exactly, functions using optional arguments with Keywords can be extended later, without breaking previous code and also allow specifying only one select optional argument. While only one would have to be added here, it would be easier to extend later.
I'm curious what others think about this argumentation.

from spork.

sogaiu avatar sogaiu commented on July 21, 2024

For sh/make-new-file, it looked like in ae9db3d, @bakpakin intended for an ordinary optional argument. May be he'd be fine with a keyword argument though.

Regarding:

file creating functions

did you have any other specific ones in mind?

from spork.

sogaiu avatar sogaiu commented on July 21, 2024

bakpakin merged #99 and I verified that the change described in #96 (comment) works on a Windows machine and a Linux machine.

Made PR - #100

from spork.

sogaiu avatar sogaiu commented on July 21, 2024

The test passes for me now.

from spork.

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.