아카이브 에 브라우저 확장을 패킹하는 프로세스를 자동화하기 위해 bash 스크립트를 만들었지 .zip
만 어떤 이유로 현재 디렉토리( public
폴더 manifest.json
및 index.html
) 의 콘텐츠 옆에 mcm_extension
폴더(상위 폴더)와 현재 폴더 및 전체 콘텐츠를 다시 압축합니다. . 따라서 나는 다음과 같이 마무리합니다.
mcm_extension/
-{current folder name}/
--public/
--manifest.json
--index.html
public/
manifest.json
index.html
대신에
public/
manifest.json
index.html
및 .mcmc.zip
mcmf.zip
스크립트는 다음과 같습니다.
# Removes .DS_Store files from a project
find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch
# Creates directories of extension if they don't exist already
mkdir -p ../mcm_extension && mkdir -p ../mcm_extension/mcmc && mkdir -p ../mcm_extension/mcmf
# Google Chrome
cp -R /Users/apple/Development/mcm/public/ /Users/apple/Development/mcm_extension/mcmc/public/
cp /Users/apple/Development/mcm/manifest.json /Users/apple/Development/mcm_extension/mcmc/manifest.json
cp /Users/apple/Development/mcm/index.html /Users/apple/Development/mcm_extension/mcmc/index.html
cd /Users/apple/Development/mcm_extension/mcmc/
zip -r /Users/apple/Development/mcm_extension/mcmc.zip *
# Mozilla Firefox
cp -R /Users/apple/Development/mcm/public/ /Users/apple/Development/mcm_extension/mcmf/public/
cp /Users/apple/Development/mcm/manifestff.json /Users/apple/Development/mcm_extension/mcmf/manifest.json
cp /Users/apple/Development/mcm/index.html /Users/apple/Development/mcm_extension/mcmf/index.html
cd /Users/apple/Development/mcm_extension/mcmf/
zip -r /Users/apple/Development/mcm_extension/mcmf.zip *
답변1
현재 디렉토리와 상위 디렉토리는 각각 .
및 로 참조됩니다 ..
.
따라서 현재 디렉터리와 상위 디렉터리를 모두 제외한 내용만 압축하려면 다음을 시도하십시오.
zip -r /path_to_folder/* -x .. -x .
상위 디렉토리만 제외하고 현재 디렉토리를 유지하려면 다음을 시도하십시오.
zip -r /path_to_folder/* -x ..
-x
옵션은 로 압축하는 동안 파일이나 디렉터리를 제외하는 것입니다 zip
.