diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2024-03-28 11:59:35 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2024-03-29 05:05:50 +0000 |
| commit | c16bdbc4cbb98c560fb7e8d4895d4d84afca2eb9 (patch) | |
| tree | 747cdeede11490a2cb7905465c5409c43a8e01ba /src | |
| parent | 8b0c14ce2dda811629a62dc30f3651057c7ec0f3 (diff) | |
| download | luarocks-c16bdbc4cbb98c560fb7e8d4895d4d84afca2eb9.tar.gz luarocks-c16bdbc4cbb98c560fb7e8d4895d4d84afca2eb9.tar.bz2 luarocks-c16bdbc4cbb98c560fb7e8d4895d4d84afca2eb9.zip | |
fix(init): check if we can create .gitignore
Fixes #1651.
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/cmd/init.lua | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/luarocks/cmd/init.lua b/src/luarocks/cmd/init.lua index b5161a9f..b5359c96 100644 --- a/src/luarocks/cmd/init.lua +++ b/src/luarocks/cmd/init.lua | |||
| @@ -46,13 +46,15 @@ local function write_gitignore(entries) | |||
| 46 | end | 46 | end |
| 47 | 47 | ||
| 48 | fd = io.open(".gitignore", gitignore and "a" or "w") | 48 | fd = io.open(".gitignore", gitignore and "a" or "w") |
| 49 | for _, entry in ipairs(entries) do | 49 | if fd then |
| 50 | entry = "/" .. entry | 50 | for _, entry in ipairs(entries) do |
| 51 | if not gitignore:find("\n"..entry.."\n", 1, true) then | 51 | entry = "/" .. entry |
| 52 | fd:write(entry.."\n") | 52 | if not gitignore:find("\n"..entry.."\n", 1, true) then |
| 53 | fd:write(entry.."\n") | ||
| 54 | end | ||
| 53 | end | 55 | end |
| 56 | fd:close() | ||
| 54 | end | 57 | end |
| 55 | fd:close() | ||
| 56 | end | 58 | end |
| 57 | 59 | ||
| 58 | local function inject_tree(tree) | 60 | local function inject_tree(tree) |
