Skip to content

Commit

Permalink
Revert "fix: use BIC_OVERWRITE when cping static/ too"
Browse files Browse the repository at this point in the history
This reverts commit d6b2e35.
  • Loading branch information
Pinjasaur committed Jul 26, 2024
1 parent d6b2e35 commit 33ceeeb
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 41 deletions.
8 changes: 2 additions & 6 deletions bic
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,7 @@ build_feed() {
build_static() {
[[ ! -d "${SRC_DIR}"/static ]] && return
log "Building /static -> /"
# Archive by default
local args=(-a)
# And, don't clobber files unless explicitly disabled
[[ -z "${BIC_OVERWRITE:-}" ]] && args+=(-n)
cp "${args[@]}" "${SRC_DIR}"/static/. "${DEST_DIR}"
cp -a "${SRC_DIR}"/static/. "${DEST_DIR}"
}

build() {
Expand All @@ -380,7 +376,7 @@ build() {
[[ "${SRC_DIR}" != "${__dir}" ]] && [[ -f "${SRC_DIR}"/.env ]] && src "${SRC_DIR}"/.env && log "Custom .env sourced"
DEST_DIR="${SRC_DIR}/${BUILD_DIR:-build}"
log "Using source directory: ${SRC_DIR}"
[[ -n "${BIC_OVERWRITE:-}" ]] && set +o noclobber && warn "Disabled overwrite protection"
[[ -n "${BIC_OVERWRITE:-}" ]] && set +o noclobber && log "Disabled 'noclobber' redirection overwrite protection"

# File system: what's missing and do we need to bail?
[[ -d "${SRC_DIR}"/pages && -f "${SRC_DIR}"/page.html ]] || warn "pages/ + page.html for pages"
Expand Down
12 changes: 5 additions & 7 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ generated site.

## Structure

For a fully-featured example, view the [demo] source code: <https://github.com/Pinjasaur/bic-example>
For a fully-featured example, view the demo source code: <https://github.com/Pinjasaur/bic-example>

```plaintext
$ tree -F --dirsfirst
Expand Down Expand Up @@ -169,11 +169,10 @@ There is an order-of-operations for how files are built, as follows:
- `feed.rss`
- static e.g. `static/*` &rarr; `/`

If you're not careful, it's possible you could overwrite an existing file e.g.
`pages/test.md` and `posts/999-test.md` both map to `/test.html`. `bic` uses the
Bash builtin `noclobber` e.g. `set -o noclobber` along with `--no-clobber` for
`cp` to protect against these scenarios. This can be disabled by setting
`BIC_OVERWRITE`. You've been warned.
If you're not careful, it's possible you could overwrite an existing
file e.g. `pages/test.md` and `posts/999-test.md` both map to `/test.html`. `bic`
uses the Bash builtin `noclobber` e.g. `set -o noclobber` to help prevent these
situations. This can be disabled by setting `BIC_OVERWRITE`.

## Showcase

Expand All @@ -182,7 +181,6 @@ Bash builtin `noclobber` e.g. `set -o noclobber` along with `--no-clobber` for
- the demo: <https://demo.bic.sh/>
- Mitch's blog: <https://fossen.dev/>
- Evan's blog: <https://evanhstanton.github.io/>
- you?

## Support

Expand Down
Empty file.
1 change: 0 additions & 1 deletion tests/overwrite-static/entry.html

This file was deleted.

Empty file removed tests/overwrite-static/index.html
Empty file.
1 change: 0 additions & 1 deletion tests/overwrite-static/page.html

This file was deleted.

3 changes: 0 additions & 3 deletions tests/overwrite-static/posts/999-test.md

This file was deleted.

1 change: 0 additions & 1 deletion tests/overwrite-static/static/test.html

This file was deleted.

Empty file removed tests/static/static/foo/bar/baz
Empty file.
23 changes: 1 addition & 22 deletions tests/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@

@test "bic copies static/ correctly" {
run ./bic tests/static
[[ "${status}" == 0 ]]
[[ -f tests/static/build/humans.txt ]]
[[ -f tests/static/build/foo/bar/baz ]]
[[ "${status}" == 0 ]]
rm -rf tests/static/build
[[ ! -d tests/static/build ]]
}
Expand Down Expand Up @@ -76,16 +75,6 @@
[[ ! -d tests/overwrite/build ]]
}

@test "bic will not overwrite by default (static)" {
run ./bic tests/overwrite-static
[[ -f tests/overwrite-static/build/test.html ]]
[[ "${status}" != 0 ]] # errored out trying to overwrite test.html
run cat tests/overwrite-static/build/test.html
[[ "${lines[0]}" == "<p>post</p>" ]]
rm -rf tests/overwrite-static/build
[[ ! -d tests/overwrite-static/build ]]
}

@test "bic will overwrite if specified" {
BIC_OVERWRITE=1 run ./bic tests/overwrite
[[ -f tests/overwrite/build/test.html ]]
Expand All @@ -96,16 +85,6 @@
[[ ! -d tests/overwrite/build ]]
}

@test "bic will overwrite if specified (static)" {
BIC_OVERWRITE=1 run ./bic tests/overwrite-static
[[ -f tests/overwrite-static/build/test.html ]]
[[ "${status}" == 0 ]] # didn't error out
run cat tests/overwrite-static/build/test.html
[[ "${lines[0]}" == "<p>static</p>" ]]
rm -rf tests/overwrite-static/build
[[ ! -d tests/overwrite-static/build ]]
}

@test "bic will honor a custom \$BUILD_DIR" {
BUILD_DIR=_site run ./bic tests/index.html
[[ -f tests/index.html/_site/index.html ]]
Expand Down

0 comments on commit 33ceeeb

Please sign in to comment.